<jupyter_start><jupyter_text>Analysis of the spread of the coronavirus Covid-19 in US 3/24/2020By <NAME>Data source: Ourworldindata.orgDAYS SINCE THE TOTAL CONFIRMED CASES OF COVID-19 REACHED 100https://github.com/owid/covid-19-data/blob/master/public/data/owid-covid-data.csv<jupyter_code>#Load dataset
import csv
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
data = pd.read_csv("owid-covid-data.csv")
data
us = data[data['iso_code']=='USA'][['date','total_cases']]
us = us.rename(columns={"date": "Date", "total_cases": "Cases"})
us.set_index('Date')
fig, axes = plt.subplots(1,2, figsize=(12,4))
us.plot(ax=axes[0], x='Date',y='Cases')
axes[0].set_xlabel('Day')
axes[0].set_title('COVID-19 cases (linear scale)')

us.plot(ax=axes[1], x='Date',y='Cases')
axes[1].set_yscale('log')
axes[1].set_xlabel('Day')
axes[1].set_title('COVID-19 cases (log scale)')

plt.show()
#Calculate the first derivative of cases
us['d1'] = us['Cases'] - us['Cases'].shift(1)

#Calculate the second derivative of cases
us['d2'] = us['d1'] - us['d1'].shift(1)

fig, axes = plt.subplots(1,2, figsize=(12,4))

us.plot(ax=axes[0], x='Date', y='d1')
axes[0].legend(labels=['New cases of COVID-19'])
axes[0].set_yscale('linear')
axes[0].set_xlabel('Day')
axes[0].set_title('new COVID-19 cases (linear scale)')

us.plot(ax=axes[1], x='Date', y='d1')
axes[1].legend(labels=['New cases of COVID-19'])
axes[1].set_yscale('log')
axes[1].set_xlabel('Day')
axes[1].set_title('new COVID-19 cases (log scale)')

plt.show()<jupyter_output><empty_output><jupyter_text>The new cases are increasing exponentially.This appears as a straight line in the log scale.  Let's analyze the change in new cases (the 2nd derivative of cases) to determine the acceleration of the trend.<jupyter_code>fig, axes = plt.subplots(1,2, figsize=(12,4))

us.plot(ax=axes[0], x='Date', y='d2')
axes[0].legend(labels=['Change in new cases of COVID-19'])
axes[0].set_yscale('linear')
axes[0].set_xlabel('Day')
axes[0].set_title('Acceleration of COVID-19 cases (linear scale)')

us.plot(ax=axes[1], x='Date', y='d2')
axes[1].legend(labels=['Change in new cases of COVID-19'])
axes[1].set_yscale('log')
axes[1].set_xlabel('Day')
axes[1].set_title('Acceleration of COVID-19 cases (log scale)')

plt.show()

#Smooth the new cases number, using a 3 day moving average, to try to see the trend in the
#change in new cases.
window=3
us['d1_smooth'] = us['d1'].rolling(window).mean()
us['d2_smooth'] = us['d1_smooth'] - us['d1_smooth'].shift(1)
fig, axes = plt.subplots(1,2, figsize=(12,4))

us.plot(ax=axes[0], x='Date', y='d2_smooth')
axes[0].legend(labels=['Change in new cases of COVID-19'])
axes[0].set_yscale('linear')
axes[0].set_xlabel('Day')
axes[0].set_title('Acceleration of COVID-19 cases (linear scale)(Smoothed)')

us.plot(ax=axes[1], x='Date', y='d2_smooth')
axes[1].legend(labels=['Change in new cases of COVID-19'])
axes[1].set_yscale('log')
axes[1].set_xlabel('Day')
axes[1].set_title('Acceleration of COVID-19 cases (log scale)(Smoothed)')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1948601171112557, 'fraction_numerical': 0.039687703318152245, 'mean_word_length': 6.925257731958763, 'pattern_counts': {'":': 2, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '107927', 'license': 'MIT', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1186, 'n_words': 261, 'path': 'Covid19.ipynb', 'repo_name': 'snives/Covid19', 'size': '3081'}