<jupyter_start><jupyter_text>COVID- [COVID Data](https://data.cdc.gov/Case-Surveillance/United-States-COVID-19-Cases-and-Deaths-by-State-o/9mfq-cb36)<jupyter_code>import pandas as pd
from datetime import datetime

df = pd.read_csv('./United_States_COVID-19_Cases_and_Deaths_by_State_over_Time.csv')
df['submission_date'] = df['submission_date'].apply(lambda s: datetime.strptime(s, '%m/%d/%Y'))
df['submission_year'] = df['submission_date'].apply(lambda d: d.year)
df['submission_month'] = df['submission_date'].apply(lambda d: d.month)
df = df.groupby(['state', 'submission_year', 'submission_month']).agg('sum')
df = df[['new_case', 'new_death']]

df.shape
df.describe()
df = df.reset_index()
df
state_df = pd.read_csv('./state-population.csv')

state_abbreviations = set(state_df.abbreviation)
state_pop = {r.abbreviation: r['2020'] for _, r in state_df.iterrows()}
df = df[df.state.isin(state_abbreviations)].reset_index(drop=True)
df
df['population'] = df.apply(lambda r: state_pop[r['state']], axis=1)
df['pnew_case'] = df.apply(lambda r: r.new_case / r.population, axis=1)
df['pnew_death'] = df.apply(lambda r: r.new_death / r.population, axis=1)
df.to_csv('./covid-monthly-cases.csv', index=False)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup