mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
fix to covid visualiser, sometimes deaths are null (#139)
This commit is contained in:
parent
eff5756354
commit
31e7288881
|
@ -8,7 +8,7 @@ statewise_covid_data = json.loads(r.content)['statewise']
|
||||||
|
|
||||||
with open('capital_data.json', 'r') as f:
|
with open('capital_data.json', 'r') as f:
|
||||||
json_text = f.read()
|
json_text = f.read()
|
||||||
|
|
||||||
city_data = json.loads(json_text)
|
city_data = json.loads(json_text)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,32 +23,33 @@ for i in range(1,len(statewise_covid_data)):
|
||||||
mp = folium.Map(location = [city_data[1]['lat'],city_data[1]['lng']],zoom_start= 5)
|
mp = folium.Map(location = [city_data[1]['lat'],city_data[1]['lng']],zoom_start= 5)
|
||||||
|
|
||||||
for i in range(len(city_data)):
|
for i in range(len(city_data)):
|
||||||
if float(city_data[i]['deaths']) > 50:
|
if "deaths" in city_data[i]:
|
||||||
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
if float(city_data[i]['deaths']) > 50:
|
||||||
popup = city_data[i]['state'],
|
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
||||||
icon=folium.Icon(color='darkred',icon_color='white',icon='remove-sign',),
|
popup = city_data[i]['state'],
|
||||||
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
icon=folium.Icon(color='darkred',icon_color='white',icon='remove-sign',),
|
||||||
).add_to(mp)
|
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
||||||
elif float(city_data[i]['deaths']) > 20:
|
).add_to(mp)
|
||||||
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
elif float(city_data[i]['deaths']) > 20:
|
||||||
popup = city_data[i]['state'],
|
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
||||||
icon=folium.Icon(color='red',icon_color='white',icon='ban-circle',),
|
popup = city_data[i]['state'],
|
||||||
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
icon=folium.Icon(color='red',icon_color='white',icon='ban-circle',),
|
||||||
).add_to(mp)
|
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
||||||
elif float(city_data[i]['deaths']) > 0:
|
).add_to(mp)
|
||||||
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
elif float(city_data[i]['deaths']) > 0:
|
||||||
popup = city_data[i]['state'],
|
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
||||||
icon=folium.Icon(color='orange',icon_color='white',icon='warning-sign',),
|
popup = city_data[i]['state'],
|
||||||
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
icon=folium.Icon(color='orange',icon_color='white',icon='warning-sign',),
|
||||||
).add_to(mp)
|
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
||||||
|
).add_to(mp)
|
||||||
elif float(city_data[i]['deaths']) == 0:
|
|
||||||
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
elif float(city_data[i]['deaths']) == 0:
|
||||||
popup = city_data[i]['state'],
|
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
|
||||||
icon=folium.Icon(color='green',icon_color='white',icon='ok-circle',),
|
popup = city_data[i]['state'],
|
||||||
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
icon=folium.Icon(color='green',icon_color='white',icon='ok-circle',),
|
||||||
).add_to(mp)
|
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
|
||||||
|
).add_to(mp)
|
||||||
|
|
||||||
mp.save('map.html')
|
mp.save('map.html')
|
||||||
|
|
||||||
os.system('firefox map.html')
|
os.system('firefox map.html')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user