Created
July 7, 2020 02:02
-
-
Save ryxcommar/4b4a9e753f79a321105af1e46bd2c57d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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