<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nagaraj Bhat</title>
    <description>The latest articles on Forem by Nagaraj Bhat (@nagarajbhat).</description>
    <link>https://forem.com/nagarajbhat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F232896%2F947d124c-6297-4c96-9d72-f8e6e725fe90.png</url>
      <title>Forem: Nagaraj Bhat</title>
      <link>https://forem.com/nagarajbhat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nagarajbhat"/>
    <language>en</language>
    <item>
      <title>Picture Pandas - Little Intro guide (Olympics data)</title>
      <dc:creator>Nagaraj Bhat</dc:creator>
      <pubDate>Sat, 06 Jun 2020 12:43:34 +0000</pubDate>
      <link>https://forem.com/nagarajbhat/picture-pandas-little-intro-guide-olympics-data-4o52</link>
      <guid>https://forem.com/nagarajbhat/picture-pandas-little-intro-guide-olympics-data-4o52</guid>
      <description>&lt;h3&gt;
  
  
  Frame the question approach
&lt;/h3&gt;

&lt;p&gt;So the idea is you are given a dataset, but more often than not it is not the ideal dataset that you can use directly in the machine learning pipeline.You need to get it as close to the ideal state as possible.And the way to do this is to ask questions to your dataset. Ask questions so that you get answers from the dataset and transform that dataset into something that can be used to get results.And the questions depend upon what results you want, or what your end goal is.&lt;/p&gt;

&lt;p&gt;Also, note that the questions don't necessarily have to come first. More often than not exploring the data, and combining different operations can give rise to a solution that can answer a question.So it is hard to tell whether the chicken came first or the egg.&lt;/p&gt;

&lt;p&gt;Eventually, the end goal is to make a dataset that is much more useful in the context of that is set out to be solved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dataset
&lt;/h3&gt;

&lt;p&gt;The dataset considered here is of &lt;a href="https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results"&gt;120 years of Olympic history athlete and results&lt;/a&gt;.Download this dataset if you want to follow along.&lt;/p&gt;

&lt;h3&gt;
  
  
  What will be covered?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Read and select data&lt;/li&gt;
&lt;li&gt;Summary statistics&lt;/li&gt;
&lt;li&gt;Group and sort data&lt;/li&gt;
&lt;li&gt;create DataFrame&lt;/li&gt;
&lt;li&gt;Combine data (merge, concat)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Pre- requesite
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Basic python knowledge&lt;/li&gt;
&lt;li&gt;Jupyter notebook setup&lt;/li&gt;
&lt;li&gt;Install pandas (pip install pandas)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the full blog here : &lt;a href="https://www.nagarajbhat.com/post/picture-pandas-little-guide/"&gt;Picture Pandas - Little Intro guide (Olympics data)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>todayilearned</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Interactive Map of Hospitals in Victoria using Python</title>
      <dc:creator>Nagaraj Bhat</dc:creator>
      <pubDate>Wed, 29 Jan 2020 22:14:00 +0000</pubDate>
      <link>https://forem.com/nagarajbhat/interactive-map-of-hospitals-in-victoria-using-python-28pj</link>
      <guid>https://forem.com/nagarajbhat/interactive-map-of-hospitals-in-victoria-using-python-28pj</guid>
      <description>&lt;p&gt;There are 325 hospitals in victoria. We will visualize them in the map such that some insights can be extracted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Purpose of this post:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mark all the hospitals in victoria using folium marker&lt;/li&gt;
&lt;li&gt;Which localities have the highest number of hospitals? - barplot&lt;/li&gt;
&lt;li&gt;Visualizing localities with the highest number of hospitals in a map using folium Circle.&lt;/li&gt;
&lt;li&gt;Creating heatmap for the density of hospitals in the region.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is used?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pandas - to read, filter and merge the data.&lt;/li&gt;
&lt;li&gt;seaborn to plot Barplot.&lt;/li&gt;
&lt;li&gt;Python's folium- Marker, Circle and Heatmap. Folium is specifically used to visualize maps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Data Reference:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Hospital locations by vic.gov.in - &lt;a href="https://discover.data.vic.gov.au/dataset/hospital-locations-spatial" rel="noopener noreferrer"&gt;here&lt;/a&gt; .&lt;/li&gt;
&lt;li&gt;Postcode details provided by Matthew Procter - &lt;a href="https://www.matthewproctor.com/australian_postcodes" rel="noopener noreferrer"&gt;here&lt;/a&gt; .&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Links :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check out my &lt;a href="https://github.com/nagarajbhat/map-hospitals-victoria" rel="noopener noreferrer"&gt;Github for all the code in this post&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Check out my &lt;a href="https://youtu.be/uZu8EZr4uYU" rel="noopener noreferrer"&gt;Youtube video on Interactive map for hospitals in Victoria&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Check out my &lt;a href="https://nagarajbhat.com/app/map-hospitals-victoria.html" rel="noopener noreferrer"&gt;Interactive Map application here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Import dependencies
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
import folium
import matplotlib.pyplot as plt
import seaborn as sns

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Load the data
&lt;/h2&gt;

&lt;p&gt;Hospital location data is provided by vic.gov.au &lt;a href="https://discover.data.vic.gov.au/dataset/hospital-locations-spatial" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = pd.read_csv('./data/hospital_locations.csv')
data.head()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep2.png" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.1: Data of hospitals in victoria&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Exploring the data
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What are the number of public and private hospitals in Victoria?
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Number of public hospitals in victoria :" ,len(data[data["Type"] == "PUBLIC"]))
print("Number of private hospitals in victoria :" ,len(data[data["Type"] == "PRIVATE"]))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_number.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_number.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.2: Number of public and private hospitals in victoria&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fields in the data:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data.columns

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_columns.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_columns.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.3: Fields in the data&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We do not require all the fields in the data, so let us &lt;strong&gt;filter&lt;/strong&gt; it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = data.filter(["Y","X","LabelName","Type","StreetNum","RoadName","RoadType","Postcode"])
df.head()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_filter.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep3_filter.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.4: Filtered data&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Mark all the hospitals in Victoria in a map using folium Marker
&lt;/h2&gt;

&lt;p&gt;We will use folium marker to mark all (325) the hospitals in Victoria.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Create a map
m = folium.Map(location=[-37.0,144], control_scale=True, zoom_start=7,attr = "text some")
df_copy = df.copy()
# loop through data to create Marker for each hospital
for i in range(0,len(df_copy)):
# html to be displayed in the popup
html="""
&amp;lt;h4&amp;gt; Hospital name: &amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['LabelName'])+ \
"""&amp;lt;h4&amp;gt;Type:&amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['Type']) +" Hospital" +\
"""&amp;lt;h4&amp;gt;Address:&amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['StreetNum'])+" "+ str(df_copy.iloc[i]['RoadName'])+" "+ str(df_copy.iloc[i]['RoadType'])
#IFrame
iframe = folium.IFrame(html=html, width=200, height=300)
popup = folium.Popup(iframe, max_width=2650)
#If you do not want html in popup this would be the alternative code -&amp;gt;
#popup = html("&amp;lt;b&amp;gt;HOSPITAL NAME:&amp;lt;/b&amp;gt; "+str(df_copy.iloc[i]['LabelName'])+"&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;b&amp;gt;TYPE:&amp;lt;/b&amp;gt; "+str(df_copy.iloc[i]['Type']) +" hospital"\
# +"&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &amp;lt;b&amp;gt;ADDRESS:&amp;lt;/B&amp;gt; " + str(df_copy.iloc[i]['StreetNum'])+" "+ str(df_copy.iloc[i]['RoadName'])+" "+ str(df_copy.iloc[i]['RoadType'])),
folium.Marker(
location=[df_copy.iloc[i]['Y'], df_copy.iloc[i]['X']],
popup=popup,
tooltip=str(df_copy.iloc[i]['LabelName']),
icon=folium.Icon(color='green',icon='medkit',prefix="fa"),
).add_to(m)
m.save("./files/hospitals.html")
m

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.nagarajbhat.com/files/map-hospitals-victoria/hospitals.html" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fhospitals.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.5: Hospitals in Victoria (click on the image for interactive map)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Custom icons can also be created using folium.features.CustomIcon&lt;/li&gt;
&lt;li&gt;In the dataframe, Y is latitude and X is longitude&lt;/li&gt;
&lt;li&gt;IFrame is a way you can use HTML in a popup since popup doesn't have HTML facility by default&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;folium.Marker arguments -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tooltip - adds hover functionality&lt;/li&gt;
&lt;li&gt;popup - string to be displayed when clicked upon the marker. We display more details here such as hospital type and address.&lt;/li&gt;
&lt;li&gt;icon - icon can be selected from font awesome, just mention the prefix ‘fa’.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Postcodes with highest number of hospitals
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df_postcode = data.groupby(['Postcode'],as_index=False)
postcode_count = df_postcode.count().filter(["Postcode","FID"])
postcode_count = postcode_count.sort_values(by="FID",ascending=False)
postcode_count

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep5.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.6: postcodes with highest number of hospitals&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Note that FID field here just indicates the count of hospitals for a given postcode&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Merge this with postcode details
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The original dataframe does not contain postcode details such as locality name, latitude, and longitude based on a given postcode.&lt;/li&gt;
&lt;li&gt;Postcode details are obtained from &lt;a href="https://www.matthewproctor.com/australian_postcodes" rel="noopener noreferrer"&gt;here&lt;/a&gt; by Matthew Procter.&lt;/li&gt;
&lt;li&gt;both the dataframes are merged based on the common key - postcode.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;australian_postcodes = pd.read_csv('./data/australian_postcodes.csv')
vic_postcodes = australian_postcodes[australian_postcodes["state"]=='VIC']
vic_postcodes = vic_postcodes.filter(["postcode","locality","lat",'long'])
vic_postcodes.head(5)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep6_postcode.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep6_postcode.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.7: postcode details data&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Merge -
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df_merged = postcode_count.merge(vic_postcodes,left_on='Postcode',right_on='postcode',how="inner")
df_merged = df_merged.dropna()
top_localities = df_merged.sort_values(by="FID",ascending=False)
top_localities

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep6_merge.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep6_merge.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.8: Merged data&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Localities with most hospitals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Note: There can be more than one locality under a single postcode.&lt;/li&gt;
&lt;li&gt;We will find out which localities have the highest number of hospitals
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top_localities_15 = top_localities.head(15)
ax = sns.barplot(top_localities_15['FID'],top_localities_15['locality'],hue=top_localities_15['postcode'])
ax.set(xlabel="count - number of hospitals",ylabel="locality",title="Localities with highest number of hospitals in Victoria")
ax

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep7_barplot.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fstep7_barplot.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.9: Localities with the most number of hospitals&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As we can see from the barplot above, The top 5 localities with most number of hospitals are East melbourne,Seddon and SeddonWest,Footscray and Frankston.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Map of the number of hospitals in a locality
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We will use the folium circle to create this map.&lt;/li&gt;
&lt;li&gt;the size of the circle represents the number of hospitals in the locality.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from folium.plugins import HeatMap
from folium.features import CustomIcon
m = folium.Map(location=[-38.0,145], control_scale=True, zoom_start=10,attr = "text some",tiles='cartodbdark_matter')
df_copy = df_merged.copy()
df_copy['count'] = 1
# create Folium circle
for i in range(0,len(df_copy)):
# html to be displayed in the popup
html="""
&amp;lt;h4&amp;gt; Locality Name: &amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['locality'])+\
"""&amp;lt;h4&amp;gt;Postcode:&amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['postcode'])+\
"""&amp;lt;h4&amp;gt;Number of hospitals:&amp;lt;/h4&amp;gt;""" + str(df_copy.iloc[i]['FID'])
#IFrame
iframe = folium.IFrame(html=html, width=200, height=300)
popup = folium.Popup(iframe, max_width=2650)
folium.Circle(
location=[df_copy.iloc[i]['lat'], df_copy.iloc[i]['long']],
radius=float(df_copy.iloc[i]['FID']*200),
popup=popup,
tooltip=str(df_copy.iloc[i]['locality']),
color='crimson',
fill=True,
fill_color='green'
).add_to(m)
m.save("./files/locality.html")
m

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.nagarajbhat.com/files/map-hospitals-victoria/locality.html" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Flocality.png" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.10: Locality view - Indicating the number of Hospitals in each locality in Victoria (click on the image for interactive map)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Disclaimer :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Also note that the circle is a just a representation for the locality. For accurate hospital locations prefer hospitals view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  9. Heatmap of the hospitals
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m = folium.Map(location=[-38.0,145], control_scale=True, zoom_start=10,attr = "text some",tiles='cartodbdark_matter')
df_copy = df.copy()
df_copy['count']=1
HeatMap(data=df_copy[['Y', 'X', 'count']].groupby(['Y', 'X']).sum().reset_index().values.tolist(),gradient={0.2: 'blue', 0.4: 'lime', 0.6: 'orange', 1: 'red'},radius=15, max_zoom=13).add_to(m)
m.save("./files/heatmap.html")
m

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.nagarajbhat.com/files/map-hospitals-victoria/heatmap.html" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.nagarajbhat.com%2Fimg%2Fmap-hospitals-victoria%2Fheatmap.PNG" alt="image"&gt;&lt;/a&gt;&lt;em&gt;Fig.11: Heatmap of Hospitals in Victoria (click on the image for interactive map)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The heatmap indicate the density of the hospitals in the region.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use cases:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;1st use case&lt;/strong&gt; - hospital view - To check for the location of hospitals in Victoria and its Address, And also the type of hospital, whether it is public or private.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Public hospitals usually offer cheaper services. And private hospitals are known for more comfort, you can choose based on your preference.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;2nd use case&lt;/strong&gt; - real estate based -in locality view- If you are looking for a place to stay in a locality with a high number of hospitals you can make a decision based on this map.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;for example, if you are deciding between Notting hill and ashwood, you might wanna prefer Notting hill as it has 6 hospitals compare to just 1 in Ashwood&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;3rd use case&lt;/strong&gt; - Travel - using heatmap - Suppose you are traveling outside Melbourne and you need to keep hospitals close by. You might prefer the route that takes you through ballarat or Bendigo over some other place like Castlemaine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We can combine all the three features, i.e hospitals, locality and the heatmap in a single map using Featuregroup and control layer.If you want to check out the &lt;strong&gt;code for combined features visit my github repository &lt;a href="https://github.com/nagarajbhat/map-hospitals-victoria" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/strong&gt; and open app.py&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To view the app (combining all three features), &lt;a href="https://www.nagarajbhat.com/app/map-hospitals-victoria.html" rel="noopener noreferrer"&gt;click here -Interactive map for hospitals in Victoria&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Also check out my youtube video for Inteactive maps in victoria -&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uZu8EZr4uYU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>python</category>
      <category>beginners</category>
      <category>visualization</category>
    </item>
    <item>
      <title>Python's Folium to create choropleth maps</title>
      <dc:creator>Nagaraj Bhat</dc:creator>
      <pubDate>Tue, 14 Jan 2020 12:43:34 +0000</pubDate>
      <link>https://forem.com/nagarajbhat/python-s-folium-to-create-choropleth-maps-8l1</link>
      <guid>https://forem.com/nagarajbhat/python-s-folium-to-create-choropleth-maps-8l1</guid>
      <description>&lt;p&gt;Folium is a built on top python and of leaflet.js. It is used to visualize data through interactive maps, choropleth visualization, as well as parsing markers on data.&lt;/p&gt;

&lt;p&gt;For ipython notebook code, checkout my &lt;a href="https://github.com/nagarajbhat/folium-visualization"&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What will be covered in this blog?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;data preparation - merging, sorting, grouping using pandas. &lt;/li&gt;
&lt;li&gt;barplot visualization using seaborn &lt;/li&gt;
&lt;li&gt;creating maps using python's folium - tiles, circle marker, choropleth map, and geojson. &lt;/li&gt;
&lt;li&gt;creating labels on the choropleth map using GeoJsonToolTip. &lt;/li&gt;
&lt;li&gt;Displaying multiple data views on the same map using feature group and control layer.&lt;/li&gt;
&lt;li&gt;Create markers and use custom icons. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the full blog here : &lt;a href="https://www.nagarajbhat.com/post/folium-visualization/"&gt;Python's Folium to create choropleth maps&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>todayilearned</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
