fix to covid visualiser, sometimes deaths are null (#139)

This commit is contained in:
joec237 2020-07-05 14:36:17 -04:00 committed by GitHub
parent eff5756354
commit 31e7288881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ statewise_covid_data = json.loads(r.content)['statewise']
with open('capital_data.json', 'r') as f:
json_text = f.read()
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)
for i in range(len(city_data)):
if float(city_data[i]['deaths']) > 50:
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
popup = city_data[i]['state'],
icon=folium.Icon(color='darkred',icon_color='white',icon='remove-sign',),
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
).add_to(mp)
elif float(city_data[i]['deaths']) > 20:
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
popup = city_data[i]['state'],
icon=folium.Icon(color='red',icon_color='white',icon='ban-circle',),
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']],
popup = city_data[i]['state'],
icon=folium.Icon(color='orange',icon_color='white',icon='warning-sign',),
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']],
popup = city_data[i]['state'],
icon=folium.Icon(color='green',icon_color='white',icon='ok-circle',),
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
).add_to(mp)
if "deaths" in city_data[i]:
if float(city_data[i]['deaths']) > 50:
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
popup = city_data[i]['state'],
icon=folium.Icon(color='darkred',icon_color='white',icon='remove-sign',),
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
).add_to(mp)
elif float(city_data[i]['deaths']) > 20:
folium.Marker(location = [city_data[i]['lat'],city_data[i]['lng']],
popup = city_data[i]['state'],
icon=folium.Icon(color='red',icon_color='white',icon='ban-circle',),
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']],
popup = city_data[i]['state'],
icon=folium.Icon(color='orange',icon_color='white',icon='warning-sign',),
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']],
popup = city_data[i]['state'],
icon=folium.Icon(color='green',icon_color='white',icon='ok-circle',),
tooltip = 'deaths: ' + city_data[i]['deaths'] + ' confirmed: ' + city_data[i]['confirmed']
).add_to(mp)
mp.save('map.html')
os.system('firefox map.html')
os.system('firefox map.html')