dailylog 5-02-20
GEORGIA GIF SCRIPT
convert -delay 30 georgia_v7*.png -delay 300 georgia_v72020-04-28.png -loop 0 georgia7.gif
NOTEBOOK: COVID-19/Untitled
import pandas as pd
import glob
import os
path = 'csse_covid_19_data/csse_covid_19_daily_reports' # use your path
all_files = glob.glob(os.path.join(path, "*.csv")) # advisable to use os.path.join as this makes concatenation OS independent
df_from_each_file = (pd.read_csv(f) for f in all_files)
concatenated_df = pd.concat(df_from_each_file, ignore_index=True)
NOTEBOOK: COVID-19/GET_CALIFORNIA_COUNTIES
import pandas as pd
import numpy as np
from urllib.request import urlopen
import json
import plotly.graph_objects as go
import plotly.express as px
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
df = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv",
dtype={"fips": str})
df_state = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv",
dtype={"fips": str})
ca = df[df['state']=='California']
def make_plot_by_dates(date):
fig = px.choropleth(ca[ca['date']==date], geojson=counties, locations='fips', color='cases',
color_continuous_scale="Viridis",
range_color=(0, 500),
scope="usa",
labels={'2020-04-25':'infection rate'}
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0}, title="hello")
fig.update_layout(
title={
'text': date,
'y':0.9,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'})
fig.show()
dates = sorted(set(df.date))
for date in dates:
make_plot_by_dates(date)
UNTESTED WITH CA
def make_plot(date):
print(date)
# date = df.columns[0]
fig = px.choropleth(ca[ca['date'] == date], geojson=counties, locations='fips', color='cases',
color_continuous_scale="Viridis",
range_color=(0, 1000),
scope="usa",
labels={'2020-04-25':'infected'}
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.update_layout(
title={
'text': date,
'y':0.9,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'},
coloraxis_colorbar=dict(
title="Number of infections",
titleside="top",
tickmode="array",
tickvals=[0, 100, 500, 1000],
ticktext=["0", "100", "500", ">1000"],
ticks="outside"
)
)
filename = 'california_' + date + '.png'
fig.write_image(filename)
fig.show()