CoCalc Public FilesVIS / tests-us.sagewsOpen with one click!
Author: Hal Snyder
Views : 161
Description: Sample worksheet: display of IL COVID-19 testing data
Compute Environment: Ubuntu 18.04 (Deprecated)

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 # url = f"" url
# 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)
positive death total
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);