Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download

Sample worksheet: display of IL COVID-19 testing data

Project: covid-19
Views: 282

COVID-19 Display US Testing Time Series

%auto %default_mode python3
import pandas as pd import numpy as np
# use testing series collected by The Covid Tracking Project # https://covidtracking.com/api/ url = f"https://covidtracking.com/api/us/daily.csv" url
'https://covidtracking.com/api/us/daily.csv'
# fetch US data from Covid Tracking Project # keep only a few columns df = pd.read_csv(url, parse_dates=['date', 'dateChecked'])[['date','positive','death','total']]
# use date as x-axis for displays so make it the index df.set_index('date', inplace=True) df.set_index(df.index.strftime('%m/%d'), inplace=True) df.sort_index(inplace=True)
df.head(2)
positive death total
date
01/22 2 NaN 2
01/23 2 NaN 2
df[-30:].plot(y=['positive','total'], kind="bar", figsize=[8, 5], rot=45, fontsize=7);
df['positive/total'] = df.loc[:,'positive']/df.loc[:,'total']
df[-30:].plot(y=['positive/total'], kind="bar", figsize=[8, 5], rot=45, fontsize=7);
# just the confirmed (positives) df[-30:].plot(y=['positive'], kind="bar", figsize=[8, 5], rot=45, fontsize=7);