Skip to content

Instantly share code, notes, and snippets.

@ryxcommar
Created July 7, 2020 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryxcommar/4b4a9e753f79a321105af1e46bd2c57d to your computer and use it in GitHub Desktop.
Save ryxcommar/4b4a9e753f79a321105af1e46bd2c57d to your computer and use it in GitHub Desktop.
import os
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import us # pip install us
# Data is available here: https://covidtracking.com/data/download
df = pd.read_csv(os.path.expanduser('~/Downloads/daily.csv'))
# Filter the data, rename stuff
df = df.loc[df['date'] == 20200706, ['state', 'total']]
df = df.rename(columns={'total': 'COVID-19 cases'})
# Define our independent variable.
df['state_full_name'] = df['state'].apply(lambda x: us.states.lookup(x).name)
df['Number of letters in state name'] = df['state_full_name'].str.replace(' ', '').str.len()
# Perform super cool epic regression
fig, ax = plt.subplots(dpi=300)
ax.set_xlim(left=-10, right=300)
sns.regplot(
x=df['Number of letters in state name'],
y=df['COVID-19 cases'],
ax=ax,
ci=None,
truncate=False
)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment