import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['figure.figsize'] = (14, 5)
mpl.rcParams['axes.grid'] = False
corona_confirmed_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv')
corona_confirmed_df.head()
Province/State | Country/Region | Lat | Long | 1/22/20 | 1/23/20 | 1/24/20 | 1/25/20 | 1/26/20 | 1/27/20 | 1/28/20 | 1/29/20 | 1/30/20 | 1/31/20 | 2/1/20 | 2/2/20 | 2/3/20 | 2/4/20 | 2/5/20 | 2/6/20 | 2/7/20 | 2/8/20 | 2/9/20 | 2/10/20 | 2/11/20 | 2/12/20 | 2/13/20 | 2/14/20 | 2/15/20 | 2/16/20 | 2/17/20 | 2/18/20 | 2/19/20 | 2/20/20 | 2/21/20 | 2/22/20 | 2/23/20 | 2/24/20 | 2/25/20 | 2/26/20 | 2/27/20 | 2/28/20 | 2/29/20 | 3/1/20 | 3/2/20 | 3/3/20 | 3/4/20 | 3/5/20 | 3/6/20 | 3/7/20 | 3/8/20 | 3/9/20 | 3/10/20 | 3/11/20 | 3/12/20 | 3/13/20 | 3/14/20 | 3/15/20 | 3/16/20 | 3/17/20 | 3/18/20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 2 | 3 | 5 | 7 | 8 | 8 | 14 | 14 | 14 | 19 | 19 | 19 | 19 | 25 | 25 | 25 | 25 | 32 | 32 | 32 | 33 | 33 | 33 | 33 | 33 | 34 | 35 | 35 | 35 | 35 | 35 | 35 | 35 | 35 | 37 | 40 | 40 | 41 | 42 | 42 | 43 | 43 | 43 | 47 | 48 | 50 | 50 | 50 | 53 | 59 | 70 | 75 | 82 | 114 | 147 | 177 | 212 |
1 | NaN | Japan | 36.0000 | 138.0000 | 2 | 1 | 2 | 2 | 4 | 4 | 7 | 7 | 11 | 15 | 20 | 20 | 20 | 22 | 22 | 45 | 25 | 25 | 26 | 26 | 26 | 28 | 28 | 29 | 43 | 59 | 66 | 74 | 84 | 94 | 105 | 122 | 147 | 159 | 170 | 189 | 214 | 228 | 241 | 256 | 274 | 293 | 331 | 360 | 420 | 461 | 502 | 511 | 581 | 639 | 639 | 701 | 773 | 839 | 825 | 878 | 889 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 0 | 1 | 3 | 3 | 4 | 5 | 7 | 7 | 10 | 13 | 16 | 18 | 18 | 24 | 28 | 28 | 30 | 33 | 40 | 45 | 47 | 50 | 58 | 67 | 72 | 75 | 77 | 81 | 84 | 84 | 85 | 85 | 89 | 89 | 91 | 93 | 93 | 93 | 102 | 106 | 108 | 110 | 110 | 117 | 130 | 138 | 150 | 150 | 160 | 178 | 178 | 200 | 212 | 226 | 243 | 266 | 313 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 0 | 0 | 0 | 3 | 4 | 4 | 4 | 7 | 8 | 8 | 8 | 8 | 8 | 10 | 12 | 12 | 12 | 16 | 16 | 18 | 18 | 18 | 19 | 19 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 23 | 23 | 25 | 29 | 29 | 36 | 50 | 50 | 83 | 93 | 99 | 117 | 129 | 149 | 149 | 197 | 238 | 428 | 566 | 673 | 790 |
corona_death_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv')
corona_death_df.head()
Province/State | Country/Region | Lat | Long | 1/22/20 | 1/23/20 | 1/24/20 | 1/25/20 | 1/26/20 | 1/27/20 | 1/28/20 | 1/29/20 | 1/30/20 | 1/31/20 | 2/1/20 | 2/2/20 | 2/3/20 | 2/4/20 | 2/5/20 | 2/6/20 | 2/7/20 | 2/8/20 | 2/9/20 | 2/10/20 | 2/11/20 | 2/12/20 | 2/13/20 | 2/14/20 | 2/15/20 | 2/16/20 | 2/17/20 | 2/18/20 | 2/19/20 | 2/20/20 | 2/21/20 | 2/22/20 | 2/23/20 | 2/24/20 | 2/25/20 | 2/26/20 | 2/27/20 | 2/28/20 | 2/29/20 | 3/1/20 | 3/2/20 | 3/3/20 | 3/4/20 | 3/5/20 | 3/6/20 | 3/7/20 | 3/8/20 | 3/9/20 | 3/10/20 | 3/11/20 | 3/12/20 | 3/13/20 | 3/14/20 | 3/15/20 | 3/16/20 | 3/17/20 | 3/18/20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
1 | NaN | Japan | 36.0000 | 138.0000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 4 | 4 | 5 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 10 | 10 | 15 | 16 | 19 | 22 | 22 | 27 | 29 | 29 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 2 |
corona_recovered_df = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv')
corona_recovered_df.head()
Province/State | Country/Region | Lat | Long | 1/22/20 | 1/23/20 | 1/24/20 | 1/25/20 | 1/26/20 | 1/27/20 | 1/28/20 | 1/29/20 | 1/30/20 | 1/31/20 | 2/1/20 | 2/2/20 | 2/3/20 | 2/4/20 | 2/5/20 | 2/6/20 | 2/7/20 | 2/8/20 | 2/9/20 | 2/10/20 | 2/11/20 | 2/12/20 | 2/13/20 | 2/14/20 | 2/15/20 | 2/16/20 | 2/17/20 | 2/18/20 | 2/19/20 | 2/20/20 | 2/21/20 | 2/22/20 | 2/23/20 | 2/24/20 | 2/25/20 | 2/26/20 | 2/27/20 | 2/28/20 | 2/29/20 | 3/1/20 | 3/2/20 | 3/3/20 | 3/4/20 | 3/5/20 | 3/6/20 | 3/7/20 | 3/8/20 | 3/9/20 | 3/10/20 | 3/11/20 | 3/12/20 | 3/13/20 | 3/14/20 | 3/15/20 | 3/16/20 | 3/17/20 | 3/18/20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 0 | 0 | 0 | 0 | 2 | 2 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 10 | 10 | 10 | 10 | 10 | 12 | 12 | 12 | 14 | 15 | 15 | 15 | 15 | 17 | 17 | 21 | 21 | 22 | 22 | 22 | 28 | 28 | 28 | 31 | 31 | 31 | 31 | 31 | 31 | 31 | 31 | 33 | 34 | 34 | 35 | 35 | 35 | 35 | 41 | 42 |
1 | NaN | Japan | 36.0000 | 138.0000 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 4 | 9 | 9 | 9 | 9 | 12 | 12 | 12 | 13 | 18 | 18 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 22 | 32 | 32 | 32 | 43 | 43 | 43 | 46 | 76 | 76 | 76 | 101 | 118 | 118 | 118 | 118 | 118 | 144 | 144 | 144 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 9 | 15 | 15 | 17 | 18 | 18 | 24 | 29 | 34 | 34 | 37 | 37 | 51 | 51 | 53 | 62 | 62 | 62 | 72 | 72 | 78 | 78 | 78 | 78 | 78 | 78 | 78 | 78 | 78 | 96 | 96 | 97 | 105 | 105 | 109 | 114 | 114 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 3 | 3 | 3 | 3 | 7 | 7 | 7 | 13 | 15 | 15 | 15 | 15 | 15 | 18 | 18 | 18 | 18 | 18 | 18 | 18 | 18 | 22 | 22 | 22 | 22 | 23 | 24 | 24 | 24 | 26 | 26 | 26 | 35 | 42 | 42 | 49 | 60 |
corona_confirmed_df=corona_confirmed_df.melt(id_vars=['Province/State','Country/Region','Lat','Long'])
corona_confirmed_df.head()
Province/State | Country/Region | Lat | Long | variable | value | |
---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 2 |
1 | NaN | Japan | 36.0000 | 138.0000 | 1/22/20 | 2 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 |
corona_confirmed_df=corona_confirmed_df.rename({'variable':'Date','value': 'Confirmed'}, axis='columns')
corona_confirmed_df.head()
Province/State | Country/Region | Lat | Long | Date | Confirmed | |
---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 2 |
1 | NaN | Japan | 36.0000 | 138.0000 | 1/22/20 | 2 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 |
corona_death_df=corona_death_df.melt(id_vars=['Province/State','Country/Region','Lat','Long'])
corona_death_df=corona_death_df.rename({'variable':'Date','value': 'Death'}, axis='columns')
corona_death_df.head()
Province/State | Country/Region | Lat | Long | Date | Death | |
---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 1/22/20 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 |
corona_recovered_df=corona_recovered_df.melt(id_vars=['Province/State','Country/Region','Lat','Long']).rename({'variable':'Date','value': 'Recovered'}, axis='columns')
corona_recovered_df.head()
Province/State | Country/Region | Lat | Long | Date | Recovered | |
---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 1/22/20 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 |
combined_df = [corona_confirmed_df, corona_death_df, corona_recovered_df]
combined_df = [df.set_index(['Province/State','Country/Region','Lat','Long','Date']) for df in combined_df]
combined_df=combined_df[0].join(combined_df[1:])
combined_df.head()
Confirmed | Death | Recovered | |||||
---|---|---|---|---|---|---|---|
Province/State | Country/Region | Lat | Long | Date | |||
NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 2 | 0 | 0 |
Japan | 36.0000 | 138.0000 | 1/22/20 | 2 | 0 | 0 | |
Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 | 0 | 0 | |
Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 | 0 | 0 | |
Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 | 0 | 0 |
combined_df=combined_df.reset_index()
combined_df.head()
Province/State | Country/Region | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 1/22/20 | 2 | 0 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 1/22/20 | 2 | 0 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 1/22/20 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 1/22/20 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 1/22/20 | 0 | 0 | 0 |
combined_df[['Lat', 'Long','Confirmed','Death','Recovered']] = combined_df[['Lat', 'Long','Confirmed','Death','Recovered']].apply(pd.to_numeric)
combined_df[['Date']] = combined_df[['Date']].apply(pd.to_datetime)
combined_df.dtypes
Province/State object Country/Region object Lat float64 Long float64 Date datetime64[ns] Confirmed int64 Death int64 Recovered int64 dtype: object
combined_df.head()
Province/State | Country/Region | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 2020-01-22 | 2 | 0 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 2020-01-22 | 2 | 0 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 2020-01-22 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 2020-01-22 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 2020-01-22 | 0 | 0 | 0 |
combined_df=combined_df.rename({'Province/State':'State','Country/Region': 'Country'}, axis='columns')
combined_df.head()
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 2020-01-22 | 2 | 0 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 2020-01-22 | 2 | 0 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 2020-01-22 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 2020-01-22 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 2020-01-22 | 0 | 0 | 0 |
combined_df.head()
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 2020-01-22 | 2 | 0 | 0 |
1 | NaN | Japan | 36.0000 | 138.0000 | 2020-01-22 | 2 | 0 | 0 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 2020-01-22 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 2020-01-22 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 2020-01-22 | 0 | 0 | 0 |
combined_df.query("Country=='US' & State=='Washington'")
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
98 | Washington | US | 47.4009 | -121.4905 | 2020-01-22 | 0 | 0 | 0 |
560 | Washington | US | 47.4009 | -121.4905 | 2020-01-23 | 0 | 0 | 0 |
1022 | Washington | US | 47.4009 | -121.4905 | 2020-01-24 | 0 | 0 | 0 |
1484 | Washington | US | 47.4009 | -121.4905 | 2020-01-25 | 0 | 0 | 0 |
1946 | Washington | US | 47.4009 | -121.4905 | 2020-01-26 | 0 | 0 | 0 |
2408 | Washington | US | 47.4009 | -121.4905 | 2020-01-27 | 0 | 0 | 0 |
2870 | Washington | US | 47.4009 | -121.4905 | 2020-01-28 | 0 | 0 | 0 |
3332 | Washington | US | 47.4009 | -121.4905 | 2020-01-29 | 0 | 0 | 0 |
3794 | Washington | US | 47.4009 | -121.4905 | 2020-01-30 | 0 | 0 | 0 |
4256 | Washington | US | 47.4009 | -121.4905 | 2020-01-31 | 0 | 0 | 0 |
4718 | Washington | US | 47.4009 | -121.4905 | 2020-02-01 | 0 | 0 | 0 |
5180 | Washington | US | 47.4009 | -121.4905 | 2020-02-02 | 0 | 0 | 0 |
5642 | Washington | US | 47.4009 | -121.4905 | 2020-02-03 | 0 | 0 | 0 |
6104 | Washington | US | 47.4009 | -121.4905 | 2020-02-04 | 0 | 0 | 0 |
6566 | Washington | US | 47.4009 | -121.4905 | 2020-02-05 | 0 | 0 | 0 |
7028 | Washington | US | 47.4009 | -121.4905 | 2020-02-06 | 0 | 0 | 0 |
7490 | Washington | US | 47.4009 | -121.4905 | 2020-02-07 | 0 | 0 | 0 |
7952 | Washington | US | 47.4009 | -121.4905 | 2020-02-08 | 0 | 0 | 0 |
8414 | Washington | US | 47.4009 | -121.4905 | 2020-02-09 | 0 | 0 | 0 |
8876 | Washington | US | 47.4009 | -121.4905 | 2020-02-10 | 0 | 0 | 0 |
9338 | Washington | US | 47.4009 | -121.4905 | 2020-02-11 | 0 | 0 | 0 |
9800 | Washington | US | 47.4009 | -121.4905 | 2020-02-12 | 0 | 0 | 0 |
10262 | Washington | US | 47.4009 | -121.4905 | 2020-02-13 | 0 | 0 | 0 |
10724 | Washington | US | 47.4009 | -121.4905 | 2020-02-14 | 0 | 0 | 0 |
11186 | Washington | US | 47.4009 | -121.4905 | 2020-02-15 | 0 | 0 | 0 |
11648 | Washington | US | 47.4009 | -121.4905 | 2020-02-16 | 0 | 0 | 0 |
12110 | Washington | US | 47.4009 | -121.4905 | 2020-02-17 | 0 | 0 | 0 |
12572 | Washington | US | 47.4009 | -121.4905 | 2020-02-18 | 0 | 0 | 0 |
13034 | Washington | US | 47.4009 | -121.4905 | 2020-02-19 | 0 | 0 | 0 |
13496 | Washington | US | 47.4009 | -121.4905 | 2020-02-20 | 0 | 0 | 0 |
13958 | Washington | US | 47.4009 | -121.4905 | 2020-02-21 | 0 | 0 | 0 |
14420 | Washington | US | 47.4009 | -121.4905 | 2020-02-22 | 0 | 0 | 0 |
14882 | Washington | US | 47.4009 | -121.4905 | 2020-02-23 | 0 | 0 | 0 |
15344 | Washington | US | 47.4009 | -121.4905 | 2020-02-24 | 0 | 0 | 0 |
15806 | Washington | US | 47.4009 | -121.4905 | 2020-02-25 | 0 | 0 | 0 |
16268 | Washington | US | 47.4009 | -121.4905 | 2020-02-26 | 0 | 0 | 0 |
16730 | Washington | US | 47.4009 | -121.4905 | 2020-02-27 | 0 | 0 | 0 |
17192 | Washington | US | 47.4009 | -121.4905 | 2020-02-28 | 0 | 0 | 0 |
17654 | Washington | US | 47.4009 | -121.4905 | 2020-02-29 | 0 | 0 | 0 |
18116 | Washington | US | 47.4009 | -121.4905 | 2020-03-01 | 0 | 0 | 0 |
18578 | Washington | US | 47.4009 | -121.4905 | 2020-03-02 | 0 | 0 | 0 |
19040 | Washington | US | 47.4009 | -121.4905 | 2020-03-03 | 0 | 0 | 0 |
19502 | Washington | US | 47.4009 | -121.4905 | 2020-03-04 | 0 | 0 | 0 |
19964 | Washington | US | 47.4009 | -121.4905 | 2020-03-05 | 0 | 0 | 0 |
20426 | Washington | US | 47.4009 | -121.4905 | 2020-03-06 | 0 | 0 | 0 |
20888 | Washington | US | 47.4009 | -121.4905 | 2020-03-07 | 0 | 0 | 0 |
21350 | Washington | US | 47.4009 | -121.4905 | 2020-03-08 | 0 | 0 | 0 |
21812 | Washington | US | 47.4009 | -121.4905 | 2020-03-09 | 0 | 0 | 0 |
22274 | Washington | US | 47.4009 | -121.4905 | 2020-03-10 | 267 | 23 | 1 |
22736 | Washington | US | 47.4009 | -121.4905 | 2020-03-11 | 366 | 29 | 1 |
23198 | Washington | US | 47.4009 | -121.4905 | 2020-03-12 | 442 | 31 | 1 |
23660 | Washington | US | 47.4009 | -121.4905 | 2020-03-13 | 568 | 37 | 1 |
24122 | Washington | US | 47.4009 | -121.4905 | 2020-03-14 | 572 | 37 | 1 |
24584 | Washington | US | 47.4009 | -121.4905 | 2020-03-15 | 643 | 40 | 1 |
25046 | Washington | US | 47.4009 | -121.4905 | 2020-03-16 | 904 | 48 | 1 |
25508 | Washington | US | 47.4009 | -121.4905 | 2020-03-17 | 1076 | 55 | 1 |
25970 | Washington | US | 47.4009 | -121.4905 | 2020-03-18 | 1014 | 55 | 0 |
combined_df.query("Country=='China' & State=='Hubei'")
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | |
---|---|---|---|---|---|---|---|---|
154 | Hubei | China | 30.9756 | 112.2707 | 2020-01-22 | 444 | 17 | 28 |
616 | Hubei | China | 30.9756 | 112.2707 | 2020-01-23 | 444 | 17 | 28 |
1078 | Hubei | China | 30.9756 | 112.2707 | 2020-01-24 | 549 | 24 | 31 |
1540 | Hubei | China | 30.9756 | 112.2707 | 2020-01-25 | 761 | 40 | 32 |
2002 | Hubei | China | 30.9756 | 112.2707 | 2020-01-26 | 1058 | 52 | 42 |
2464 | Hubei | China | 30.9756 | 112.2707 | 2020-01-27 | 1423 | 76 | 45 |
2926 | Hubei | China | 30.9756 | 112.2707 | 2020-01-28 | 3554 | 125 | 80 |
3388 | Hubei | China | 30.9756 | 112.2707 | 2020-01-29 | 3554 | 125 | 88 |
3850 | Hubei | China | 30.9756 | 112.2707 | 2020-01-30 | 4903 | 162 | 90 |
4312 | Hubei | China | 30.9756 | 112.2707 | 2020-01-31 | 5806 | 204 | 141 |
4774 | Hubei | China | 30.9756 | 112.2707 | 2020-02-01 | 7153 | 249 | 168 |
5236 | Hubei | China | 30.9756 | 112.2707 | 2020-02-02 | 11177 | 350 | 295 |
5698 | Hubei | China | 30.9756 | 112.2707 | 2020-02-03 | 13522 | 414 | 386 |
6160 | Hubei | China | 30.9756 | 112.2707 | 2020-02-04 | 16678 | 479 | 522 |
6622 | Hubei | China | 30.9756 | 112.2707 | 2020-02-05 | 19665 | 549 | 633 |
7084 | Hubei | China | 30.9756 | 112.2707 | 2020-02-06 | 22112 | 618 | 817 |
7546 | Hubei | China | 30.9756 | 112.2707 | 2020-02-07 | 24953 | 699 | 1115 |
8008 | Hubei | China | 30.9756 | 112.2707 | 2020-02-08 | 27100 | 780 | 1439 |
8470 | Hubei | China | 30.9756 | 112.2707 | 2020-02-09 | 29631 | 871 | 1795 |
8932 | Hubei | China | 30.9756 | 112.2707 | 2020-02-10 | 31728 | 974 | 2222 |
9394 | Hubei | China | 30.9756 | 112.2707 | 2020-02-11 | 33366 | 1068 | 2639 |
9856 | Hubei | China | 30.9756 | 112.2707 | 2020-02-12 | 33366 | 1068 | 2686 |
10318 | Hubei | China | 30.9756 | 112.2707 | 2020-02-13 | 48206 | 1310 | 3459 |
10780 | Hubei | China | 30.9756 | 112.2707 | 2020-02-14 | 54406 | 1457 | 4774 |
11242 | Hubei | China | 30.9756 | 112.2707 | 2020-02-15 | 56249 | 1596 | 5623 |
11704 | Hubei | China | 30.9756 | 112.2707 | 2020-02-16 | 58182 | 1696 | 6639 |
12166 | Hubei | China | 30.9756 | 112.2707 | 2020-02-17 | 59989 | 1789 | 7862 |
12628 | Hubei | China | 30.9756 | 112.2707 | 2020-02-18 | 61682 | 1921 | 9128 |
13090 | Hubei | China | 30.9756 | 112.2707 | 2020-02-19 | 62031 | 2029 | 10337 |
13552 | Hubei | China | 30.9756 | 112.2707 | 2020-02-20 | 62442 | 2144 | 11788 |
14014 | Hubei | China | 30.9756 | 112.2707 | 2020-02-21 | 62662 | 2144 | 11881 |
14476 | Hubei | China | 30.9756 | 112.2707 | 2020-02-22 | 64084 | 2346 | 15299 |
14938 | Hubei | China | 30.9756 | 112.2707 | 2020-02-23 | 64084 | 2346 | 15343 |
15400 | Hubei | China | 30.9756 | 112.2707 | 2020-02-24 | 64287 | 2495 | 16748 |
15862 | Hubei | China | 30.9756 | 112.2707 | 2020-02-25 | 64786 | 2563 | 18971 |
16324 | Hubei | China | 30.9756 | 112.2707 | 2020-02-26 | 65187 | 2615 | 20969 |
16786 | Hubei | China | 30.9756 | 112.2707 | 2020-02-27 | 65596 | 2641 | 23383 |
17248 | Hubei | China | 30.9756 | 112.2707 | 2020-02-28 | 65914 | 2682 | 26403 |
17710 | Hubei | China | 30.9756 | 112.2707 | 2020-02-29 | 66337 | 2727 | 28993 |
18172 | Hubei | China | 30.9756 | 112.2707 | 2020-03-01 | 66907 | 2761 | 31536 |
18634 | Hubei | China | 30.9756 | 112.2707 | 2020-03-02 | 67103 | 2803 | 33934 |
19096 | Hubei | China | 30.9756 | 112.2707 | 2020-03-03 | 67217 | 2835 | 36208 |
19558 | Hubei | China | 30.9756 | 112.2707 | 2020-03-04 | 67332 | 2871 | 38557 |
20020 | Hubei | China | 30.9756 | 112.2707 | 2020-03-05 | 67466 | 2902 | 40592 |
20482 | Hubei | China | 30.9756 | 112.2707 | 2020-03-06 | 67592 | 2931 | 42033 |
20944 | Hubei | China | 30.9756 | 112.2707 | 2020-03-07 | 67666 | 2959 | 43500 |
21406 | Hubei | China | 30.9756 | 112.2707 | 2020-03-08 | 67707 | 2986 | 45235 |
21868 | Hubei | China | 30.9756 | 112.2707 | 2020-03-09 | 67743 | 3008 | 46488 |
22330 | Hubei | China | 30.9756 | 112.2707 | 2020-03-10 | 67760 | 3024 | 47743 |
22792 | Hubei | China | 30.9756 | 112.2707 | 2020-03-11 | 67773 | 3046 | 49134 |
23254 | Hubei | China | 30.9756 | 112.2707 | 2020-03-12 | 67781 | 3056 | 50318 |
23716 | Hubei | China | 30.9756 | 112.2707 | 2020-03-13 | 67786 | 3062 | 51553 |
24178 | Hubei | China | 30.9756 | 112.2707 | 2020-03-14 | 67790 | 3075 | 52960 |
24640 | Hubei | China | 30.9756 | 112.2707 | 2020-03-15 | 67794 | 3085 | 54288 |
25102 | Hubei | China | 30.9756 | 112.2707 | 2020-03-16 | 67798 | 3099 | 55142 |
25564 | Hubei | China | 30.9756 | 112.2707 | 2020-03-17 | 67799 | 3111 | 56003 |
26026 | Hubei | China | 30.9756 | 112.2707 | 2020-03-18 | 67800 | 3122 | 56927 |
combined_df['Active']=combined_df['Confirmed'] - combined_df['Death'] - combined_df['Recovered']
combined_df.query("Country=='China' & State=='Hubei'")
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | Active | |
---|---|---|---|---|---|---|---|---|---|
154 | Hubei | China | 30.9756 | 112.2707 | 2020-01-22 | 444 | 17 | 28 | 399 |
616 | Hubei | China | 30.9756 | 112.2707 | 2020-01-23 | 444 | 17 | 28 | 399 |
1078 | Hubei | China | 30.9756 | 112.2707 | 2020-01-24 | 549 | 24 | 31 | 494 |
1540 | Hubei | China | 30.9756 | 112.2707 | 2020-01-25 | 761 | 40 | 32 | 689 |
2002 | Hubei | China | 30.9756 | 112.2707 | 2020-01-26 | 1058 | 52 | 42 | 964 |
2464 | Hubei | China | 30.9756 | 112.2707 | 2020-01-27 | 1423 | 76 | 45 | 1302 |
2926 | Hubei | China | 30.9756 | 112.2707 | 2020-01-28 | 3554 | 125 | 80 | 3349 |
3388 | Hubei | China | 30.9756 | 112.2707 | 2020-01-29 | 3554 | 125 | 88 | 3341 |
3850 | Hubei | China | 30.9756 | 112.2707 | 2020-01-30 | 4903 | 162 | 90 | 4651 |
4312 | Hubei | China | 30.9756 | 112.2707 | 2020-01-31 | 5806 | 204 | 141 | 5461 |
4774 | Hubei | China | 30.9756 | 112.2707 | 2020-02-01 | 7153 | 249 | 168 | 6736 |
5236 | Hubei | China | 30.9756 | 112.2707 | 2020-02-02 | 11177 | 350 | 295 | 10532 |
5698 | Hubei | China | 30.9756 | 112.2707 | 2020-02-03 | 13522 | 414 | 386 | 12722 |
6160 | Hubei | China | 30.9756 | 112.2707 | 2020-02-04 | 16678 | 479 | 522 | 15677 |
6622 | Hubei | China | 30.9756 | 112.2707 | 2020-02-05 | 19665 | 549 | 633 | 18483 |
7084 | Hubei | China | 30.9756 | 112.2707 | 2020-02-06 | 22112 | 618 | 817 | 20677 |
7546 | Hubei | China | 30.9756 | 112.2707 | 2020-02-07 | 24953 | 699 | 1115 | 23139 |
8008 | Hubei | China | 30.9756 | 112.2707 | 2020-02-08 | 27100 | 780 | 1439 | 24881 |
8470 | Hubei | China | 30.9756 | 112.2707 | 2020-02-09 | 29631 | 871 | 1795 | 26965 |
8932 | Hubei | China | 30.9756 | 112.2707 | 2020-02-10 | 31728 | 974 | 2222 | 28532 |
9394 | Hubei | China | 30.9756 | 112.2707 | 2020-02-11 | 33366 | 1068 | 2639 | 29659 |
9856 | Hubei | China | 30.9756 | 112.2707 | 2020-02-12 | 33366 | 1068 | 2686 | 29612 |
10318 | Hubei | China | 30.9756 | 112.2707 | 2020-02-13 | 48206 | 1310 | 3459 | 43437 |
10780 | Hubei | China | 30.9756 | 112.2707 | 2020-02-14 | 54406 | 1457 | 4774 | 48175 |
11242 | Hubei | China | 30.9756 | 112.2707 | 2020-02-15 | 56249 | 1596 | 5623 | 49030 |
11704 | Hubei | China | 30.9756 | 112.2707 | 2020-02-16 | 58182 | 1696 | 6639 | 49847 |
12166 | Hubei | China | 30.9756 | 112.2707 | 2020-02-17 | 59989 | 1789 | 7862 | 50338 |
12628 | Hubei | China | 30.9756 | 112.2707 | 2020-02-18 | 61682 | 1921 | 9128 | 50633 |
13090 | Hubei | China | 30.9756 | 112.2707 | 2020-02-19 | 62031 | 2029 | 10337 | 49665 |
13552 | Hubei | China | 30.9756 | 112.2707 | 2020-02-20 | 62442 | 2144 | 11788 | 48510 |
14014 | Hubei | China | 30.9756 | 112.2707 | 2020-02-21 | 62662 | 2144 | 11881 | 48637 |
14476 | Hubei | China | 30.9756 | 112.2707 | 2020-02-22 | 64084 | 2346 | 15299 | 46439 |
14938 | Hubei | China | 30.9756 | 112.2707 | 2020-02-23 | 64084 | 2346 | 15343 | 46395 |
15400 | Hubei | China | 30.9756 | 112.2707 | 2020-02-24 | 64287 | 2495 | 16748 | 45044 |
15862 | Hubei | China | 30.9756 | 112.2707 | 2020-02-25 | 64786 | 2563 | 18971 | 43252 |
16324 | Hubei | China | 30.9756 | 112.2707 | 2020-02-26 | 65187 | 2615 | 20969 | 41603 |
16786 | Hubei | China | 30.9756 | 112.2707 | 2020-02-27 | 65596 | 2641 | 23383 | 39572 |
17248 | Hubei | China | 30.9756 | 112.2707 | 2020-02-28 | 65914 | 2682 | 26403 | 36829 |
17710 | Hubei | China | 30.9756 | 112.2707 | 2020-02-29 | 66337 | 2727 | 28993 | 34617 |
18172 | Hubei | China | 30.9756 | 112.2707 | 2020-03-01 | 66907 | 2761 | 31536 | 32610 |
18634 | Hubei | China | 30.9756 | 112.2707 | 2020-03-02 | 67103 | 2803 | 33934 | 30366 |
19096 | Hubei | China | 30.9756 | 112.2707 | 2020-03-03 | 67217 | 2835 | 36208 | 28174 |
19558 | Hubei | China | 30.9756 | 112.2707 | 2020-03-04 | 67332 | 2871 | 38557 | 25904 |
20020 | Hubei | China | 30.9756 | 112.2707 | 2020-03-05 | 67466 | 2902 | 40592 | 23972 |
20482 | Hubei | China | 30.9756 | 112.2707 | 2020-03-06 | 67592 | 2931 | 42033 | 22628 |
20944 | Hubei | China | 30.9756 | 112.2707 | 2020-03-07 | 67666 | 2959 | 43500 | 21207 |
21406 | Hubei | China | 30.9756 | 112.2707 | 2020-03-08 | 67707 | 2986 | 45235 | 19486 |
21868 | Hubei | China | 30.9756 | 112.2707 | 2020-03-09 | 67743 | 3008 | 46488 | 18247 |
22330 | Hubei | China | 30.9756 | 112.2707 | 2020-03-10 | 67760 | 3024 | 47743 | 16993 |
22792 | Hubei | China | 30.9756 | 112.2707 | 2020-03-11 | 67773 | 3046 | 49134 | 15593 |
23254 | Hubei | China | 30.9756 | 112.2707 | 2020-03-12 | 67781 | 3056 | 50318 | 14407 |
23716 | Hubei | China | 30.9756 | 112.2707 | 2020-03-13 | 67786 | 3062 | 51553 | 13171 |
24178 | Hubei | China | 30.9756 | 112.2707 | 2020-03-14 | 67790 | 3075 | 52960 | 11755 |
24640 | Hubei | China | 30.9756 | 112.2707 | 2020-03-15 | 67794 | 3085 | 54288 | 10421 |
25102 | Hubei | China | 30.9756 | 112.2707 | 2020-03-16 | 67798 | 3099 | 55142 | 9557 |
25564 | Hubei | China | 30.9756 | 112.2707 | 2020-03-17 | 67799 | 3111 | 56003 | 8685 |
26026 | Hubei | China | 30.9756 | 112.2707 | 2020-03-18 | 67800 | 3122 | 56927 | 7751 |
max_df=combined_df[combined_df.Date==combined_df['Date'].max()]
Country by Max active cases
max_df[['Country','Active']].sort_values('Active',ascending=False).head(10)
Country | Active | |
---|---|---|
25888 | Italy | 28710 |
25890 | Spain | 12206 |
25883 | Germany | 12194 |
26027 | Iran | 10837 |
26029 | France | 8883 |
26026 | China | 7751 |
26028 | Korea, South | 6789 |
25903 | Switzerland | 2985 |
26275 | United Kingdom | 2490 |
25971 | US | 2479 |
max_df[['Country','Confirmed']].groupby(['Country']).sum().sort_values('Confirmed',ascending=False).head(10)
Confirmed | |
---|---|
Country | |
China | 81102 |
Italy | 35713 |
Iran | 17361 |
Spain | 13910 |
Germany | 12327 |
France | 9105 |
Korea, South | 8413 |
US | 7783 |
Switzerland | 3028 |
United Kingdom | 2642 |
combined_df[['Date','Country','State','Active']].query("Country=='China' & State=='Hubei'").plot(x='Date',y='Active',kind='bar', title="Corona Trend for Country China and State Hubei")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e341748>
On 23 January 2020, the central government of China imposed a lockdown in Wuhan and other cities in Hubei province
On 2 February 2020, China implemented a seven-day lockdown in which only one person per household was allowed to exit once each two days, and most of the highway exits were closed
On 13 March 2020, Huangshi and Qianjiang became the first Hubei cities to remove strict travel restrictions within part or all of their administrative confines
combined_df[['Date','Country','State','Active']].groupby(['Date','Country']).sum().query("Country=='China'").reset_index().plot(x='Date',y='Active',kind='bar',title="Corona Trend for Country China")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e2707b8>
South Korea did not lockdown
South Korea tests anyone who had been in contact with a confirmed case, and tracks down by credit card activity, surveillance camera footage and mobile phone tracking those who are potentially exposed, a measure that has proved effective but has raised questions about privacy
South Korea had conducted almost 250,000 tests
Source - Forbes
combined_df[['Date','Country','State','Active']].query("Country=='Korea, South'").plot(x='Date',y='Active',kind='bar',title="Corona Trend for Country South Korea")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e90bd30>
combined_df[['Date','Country','State','Active']].query("Country=='Italy'").plot(x='Date',y='Active',kind='bar', title="Corona Trend for Country Italy")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e5b3748>
combined_df[['Date','Country','State','Active']].query("Country=='Iran'").plot(x='Date',y='Active',kind='bar', title="Corona Trend for Country Iran")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e44fda0>
combined_df[['Date','Country','State','Active']].query("Country=='US' & State=='Washington'").plot(x='Date',y='Active',kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0ceb40f0>
combined_df[['Date','Country','State','Active']].query("Country=='US' & State=='New York'").plot(x='Date',y='Active',kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0cd220b8>
combined_df[['Date','Country','State','Active']].groupby(['Date','Country']).sum().query("Country=='US'").reset_index().plot(x='Date',y='Active',kind='bar',title="Corona Trend for Country USA")
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0cb9ff98>
combined_df[['Date','Country','State','Active']].query("Country=='India'").plot(x='Date',y='Active',kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0e583d68>
combined_df.query("Country=='India'")
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | Active | |
---|---|---|---|---|---|---|---|---|---|
15 | NaN | India | 21.0 | 78.0 | 2020-01-22 | 0 | 0 | 0 | 0 |
477 | NaN | India | 21.0 | 78.0 | 2020-01-23 | 0 | 0 | 0 | 0 |
939 | NaN | India | 21.0 | 78.0 | 2020-01-24 | 0 | 0 | 0 | 0 |
1401 | NaN | India | 21.0 | 78.0 | 2020-01-25 | 0 | 0 | 0 | 0 |
1863 | NaN | India | 21.0 | 78.0 | 2020-01-26 | 0 | 0 | 0 | 0 |
2325 | NaN | India | 21.0 | 78.0 | 2020-01-27 | 0 | 0 | 0 | 0 |
2787 | NaN | India | 21.0 | 78.0 | 2020-01-28 | 0 | 0 | 0 | 0 |
3249 | NaN | India | 21.0 | 78.0 | 2020-01-29 | 0 | 0 | 0 | 0 |
3711 | NaN | India | 21.0 | 78.0 | 2020-01-30 | 1 | 0 | 0 | 1 |
4173 | NaN | India | 21.0 | 78.0 | 2020-01-31 | 1 | 0 | 0 | 1 |
4635 | NaN | India | 21.0 | 78.0 | 2020-02-01 | 1 | 0 | 0 | 1 |
5097 | NaN | India | 21.0 | 78.0 | 2020-02-02 | 2 | 0 | 0 | 2 |
5559 | NaN | India | 21.0 | 78.0 | 2020-02-03 | 3 | 0 | 0 | 3 |
6021 | NaN | India | 21.0 | 78.0 | 2020-02-04 | 3 | 0 | 0 | 3 |
6483 | NaN | India | 21.0 | 78.0 | 2020-02-05 | 3 | 0 | 0 | 3 |
6945 | NaN | India | 21.0 | 78.0 | 2020-02-06 | 3 | 0 | 0 | 3 |
7407 | NaN | India | 21.0 | 78.0 | 2020-02-07 | 3 | 0 | 0 | 3 |
7869 | NaN | India | 21.0 | 78.0 | 2020-02-08 | 3 | 0 | 0 | 3 |
8331 | NaN | India | 21.0 | 78.0 | 2020-02-09 | 3 | 0 | 0 | 3 |
8793 | NaN | India | 21.0 | 78.0 | 2020-02-10 | 3 | 0 | 0 | 3 |
9255 | NaN | India | 21.0 | 78.0 | 2020-02-11 | 3 | 0 | 0 | 3 |
9717 | NaN | India | 21.0 | 78.0 | 2020-02-12 | 3 | 0 | 0 | 3 |
10179 | NaN | India | 21.0 | 78.0 | 2020-02-13 | 3 | 0 | 0 | 3 |
10641 | NaN | India | 21.0 | 78.0 | 2020-02-14 | 3 | 0 | 0 | 3 |
11103 | NaN | India | 21.0 | 78.0 | 2020-02-15 | 3 | 0 | 0 | 3 |
11565 | NaN | India | 21.0 | 78.0 | 2020-02-16 | 3 | 0 | 3 | 0 |
12027 | NaN | India | 21.0 | 78.0 | 2020-02-17 | 3 | 0 | 3 | 0 |
12489 | NaN | India | 21.0 | 78.0 | 2020-02-18 | 3 | 0 | 3 | 0 |
12951 | NaN | India | 21.0 | 78.0 | 2020-02-19 | 3 | 0 | 3 | 0 |
13413 | NaN | India | 21.0 | 78.0 | 2020-02-20 | 3 | 0 | 3 | 0 |
13875 | NaN | India | 21.0 | 78.0 | 2020-02-21 | 3 | 0 | 3 | 0 |
14337 | NaN | India | 21.0 | 78.0 | 2020-02-22 | 3 | 0 | 3 | 0 |
14799 | NaN | India | 21.0 | 78.0 | 2020-02-23 | 3 | 0 | 3 | 0 |
15261 | NaN | India | 21.0 | 78.0 | 2020-02-24 | 3 | 0 | 3 | 0 |
15723 | NaN | India | 21.0 | 78.0 | 2020-02-25 | 3 | 0 | 3 | 0 |
16185 | NaN | India | 21.0 | 78.0 | 2020-02-26 | 3 | 0 | 3 | 0 |
16647 | NaN | India | 21.0 | 78.0 | 2020-02-27 | 3 | 0 | 3 | 0 |
17109 | NaN | India | 21.0 | 78.0 | 2020-02-28 | 3 | 0 | 3 | 0 |
17571 | NaN | India | 21.0 | 78.0 | 2020-02-29 | 3 | 0 | 3 | 0 |
18033 | NaN | India | 21.0 | 78.0 | 2020-03-01 | 3 | 0 | 3 | 0 |
18495 | NaN | India | 21.0 | 78.0 | 2020-03-02 | 5 | 0 | 3 | 2 |
18957 | NaN | India | 21.0 | 78.0 | 2020-03-03 | 5 | 0 | 3 | 2 |
19419 | NaN | India | 21.0 | 78.0 | 2020-03-04 | 28 | 0 | 3 | 25 |
19881 | NaN | India | 21.0 | 78.0 | 2020-03-05 | 30 | 0 | 3 | 27 |
20343 | NaN | India | 21.0 | 78.0 | 2020-03-06 | 31 | 0 | 3 | 28 |
20805 | NaN | India | 21.0 | 78.0 | 2020-03-07 | 34 | 0 | 3 | 31 |
21267 | NaN | India | 21.0 | 78.0 | 2020-03-08 | 39 | 0 | 3 | 36 |
21729 | NaN | India | 21.0 | 78.0 | 2020-03-09 | 43 | 0 | 3 | 40 |
22191 | NaN | India | 21.0 | 78.0 | 2020-03-10 | 56 | 0 | 4 | 52 |
22653 | NaN | India | 21.0 | 78.0 | 2020-03-11 | 62 | 1 | 4 | 57 |
23115 | NaN | India | 21.0 | 78.0 | 2020-03-12 | 73 | 1 | 4 | 68 |
23577 | NaN | India | 21.0 | 78.0 | 2020-03-13 | 82 | 2 | 4 | 76 |
24039 | NaN | India | 21.0 | 78.0 | 2020-03-14 | 102 | 2 | 4 | 96 |
24501 | NaN | India | 21.0 | 78.0 | 2020-03-15 | 113 | 2 | 13 | 98 |
24963 | NaN | India | 21.0 | 78.0 | 2020-03-16 | 119 | 2 | 13 | 104 |
25425 | NaN | India | 21.0 | 78.0 | 2020-03-17 | 142 | 3 | 14 | 125 |
25887 | NaN | India | 21.0 | 78.0 | 2020-03-18 | 156 | 3 | 14 | 139 |
combined_df[['Date','Country','State','Active']].query("Country=='US' & State=='Arizona'").plot(x='Date',y='Active',kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0c8a5550>
combined_df[['Date','Country','State','Active']].query("Country=='Brazil'").plot(x='Date',y='Active',kind='bar')
<matplotlib.axes._subplots.AxesSubplot at 0x7efe0c723668>
combined_df.head()
State | Country | Lat | Long | Date | Confirmed | Death | Recovered | Active | |
---|---|---|---|---|---|---|---|---|---|
0 | NaN | Thailand | 15.0000 | 101.0000 | 2020-01-22 | 2 | 0 | 0 | 2 |
1 | NaN | Japan | 36.0000 | 138.0000 | 2020-01-22 | 2 | 0 | 0 | 2 |
2 | NaN | Singapore | 1.2833 | 103.8333 | 2020-01-22 | 0 | 0 | 0 | 0 |
3 | NaN | Nepal | 28.1667 | 84.2500 | 2020-01-22 | 0 | 0 | 0 | 0 |
4 | NaN | Malaysia | 2.5000 | 112.5000 | 2020-01-22 | 0 | 0 | 0 | 0 |
indexed_df=combined_df.set_index('Date')
indexed_df.head()
State | Country | Lat | Long | Confirmed | Death | Recovered | Active | |
---|---|---|---|---|---|---|---|---|
Date | ||||||||
2020-01-22 | NaN | Thailand | 15.0000 | 101.0000 | 2 | 0 | 0 | 2 |
2020-01-22 | NaN | Japan | 36.0000 | 138.0000 | 2 | 0 | 0 | 2 |
2020-01-22 | NaN | Singapore | 1.2833 | 103.8333 | 0 | 0 | 0 | 0 |
2020-01-22 | NaN | Nepal | 28.1667 | 84.2500 | 0 | 0 | 0 | 0 |
2020-01-22 | NaN | Malaysia | 2.5000 | 112.5000 | 0 | 0 | 0 | 0 |
indexed_prev = indexed_df[['Country','State','Active']].copy()
indexed_prev=indexed_prev.reset_index()
indexed_prev
Date | Country | State | Active | |
---|---|---|---|---|
0 | 2020-01-22 | Thailand | NaN | 2 |
1 | 2020-01-22 | Japan | NaN | 2 |
2 | 2020-01-22 | Singapore | NaN | 0 |
3 | 2020-01-22 | Nepal | NaN | 0 |
4 | 2020-01-22 | Malaysia | NaN | 0 |
... | ... | ... | ... | ... |
26329 | 2020-03-18 | Netherlands | Aruba | 4 |
26330 | 2020-03-18 | Zambia | NaN | 2 |
26331 | 2020-03-18 | Djibouti | NaN | 1 |
26332 | 2020-03-18 | Gambia, The | NaN | 1 |
26333 | 2020-03-18 | United Kingdom | Montserrat | 1 |
26334 rows × 4 columns
indexed_prev.sort_values('Date').sort_values(['Country','State'])
Date | Country | State | Active | |
---|---|---|---|---|
26 | 2020-01-22 | Afghanistan | NaN | 0 |
488 | 2020-01-23 | Afghanistan | NaN | 0 |
950 | 2020-01-24 | Afghanistan | NaN | 0 |
1412 | 2020-01-25 | Afghanistan | NaN | 0 |
1874 | 2020-01-26 | Afghanistan | NaN | 0 |
... | ... | ... | ... | ... |
24482 | 2020-03-14 | Zambia | NaN | 0 |
24944 | 2020-03-15 | Zambia | NaN | 0 |
25406 | 2020-03-16 | Zambia | NaN | 0 |
25868 | 2020-03-17 | Zambia | NaN | 0 |
26330 | 2020-03-18 | Zambia | NaN | 2 |
26334 rows × 4 columns
indexed_prev['prev_active']=indexed_prev.sort_values('Date').sort_values(['Country','State'])['Active'].shift(1)
indexed_prev['total_increase']=indexed_prev['Active'] - indexed_prev['prev_active']
indexed_prev.head(100)
Date | Country | State | Active | prev_active | total_increase | |
---|---|---|---|---|---|---|
0 | 2020-01-22 | Thailand | NaN | 2 | 3.0 | -1.0 |
1 | 2020-01-22 | Japan | NaN | 2 | 11.0 | -9.0 |
2 | 2020-01-22 | Singapore | NaN | 0 | 4.0 | -4.0 |
3 | 2020-01-22 | Nepal | NaN | 0 | 2.0 | -2.0 |
4 | 2020-01-22 | Malaysia | NaN | 0 | 201.0 | -201.0 |
... | ... | ... | ... | ... | ... | ... |
95 | 2020-01-22 | Albania | NaN | 0 | 21.0 | -21.0 |
96 | 2020-01-22 | Cyprus | NaN | 0 | 6.0 | -6.0 |
97 | 2020-01-22 | Brunei | NaN | 0 | 367.0 | -367.0 |
98 | 2020-01-22 | US | Washington | 0 | 0.0 | 0.0 |
99 | 2020-01-22 | US | New York | 0 | 23.0 | -23.0 |
100 rows × 6 columns
indexed_prev.query("Country=='US' & State=='New York'")
Date | Country | State | Active | prev_active | total_increase | |
---|---|---|---|---|---|---|
99 | 2020-01-22 | US | New York | 0 | 23.0 | -23.0 |
561 | 2020-01-23 | US | New York | 0 | 0.0 | 0.0 |
1023 | 2020-01-24 | US | New York | 0 | 0.0 | 0.0 |
1485 | 2020-01-25 | US | New York | 0 | 0.0 | 0.0 |
1947 | 2020-01-26 | US | New York | 0 | 0.0 | 0.0 |
2409 | 2020-01-27 | US | New York | 0 | 0.0 | 0.0 |
2871 | 2020-01-28 | US | New York | 0 | 0.0 | 0.0 |
3333 | 2020-01-29 | US | New York | 0 | 0.0 | 0.0 |
3795 | 2020-01-30 | US | New York | 0 | 0.0 | 0.0 |
4257 | 2020-01-31 | US | New York | 0 | 0.0 | 0.0 |
4719 | 2020-02-01 | US | New York | 0 | 0.0 | 0.0 |
5181 | 2020-02-02 | US | New York | 0 | 0.0 | 0.0 |
5643 | 2020-02-03 | US | New York | 0 | 0.0 | 0.0 |
6105 | 2020-02-04 | US | New York | 0 | 0.0 | 0.0 |
6567 | 2020-02-05 | US | New York | 0 | 0.0 | 0.0 |
7029 | 2020-02-06 | US | New York | 0 | 0.0 | 0.0 |
7491 | 2020-02-07 | US | New York | 0 | 0.0 | 0.0 |
7953 | 2020-02-08 | US | New York | 0 | 0.0 | 0.0 |
8415 | 2020-02-09 | US | New York | 0 | 0.0 | 0.0 |
8877 | 2020-02-10 | US | New York | 0 | 0.0 | 0.0 |
9339 | 2020-02-11 | US | New York | 0 | 0.0 | 0.0 |
9801 | 2020-02-12 | US | New York | 0 | 0.0 | 0.0 |
10263 | 2020-02-13 | US | New York | 0 | 0.0 | 0.0 |
10725 | 2020-02-14 | US | New York | 0 | 0.0 | 0.0 |
11187 | 2020-02-15 | US | New York | 0 | 0.0 | 0.0 |
11649 | 2020-02-16 | US | New York | 0 | 0.0 | 0.0 |
12111 | 2020-02-17 | US | New York | 0 | 0.0 | 0.0 |
12573 | 2020-02-18 | US | New York | 0 | 0.0 | 0.0 |
13035 | 2020-02-19 | US | New York | 0 | 0.0 | 0.0 |
13497 | 2020-02-20 | US | New York | 0 | 0.0 | 0.0 |
13959 | 2020-02-21 | US | New York | 0 | 0.0 | 0.0 |
14421 | 2020-02-22 | US | New York | 0 | 0.0 | 0.0 |
14883 | 2020-02-23 | US | New York | 0 | 0.0 | 0.0 |
15345 | 2020-02-24 | US | New York | 0 | 0.0 | 0.0 |
15807 | 2020-02-25 | US | New York | 0 | 0.0 | 0.0 |
16269 | 2020-02-26 | US | New York | 0 | 0.0 | 0.0 |
16731 | 2020-02-27 | US | New York | 0 | 0.0 | 0.0 |
17193 | 2020-02-28 | US | New York | 0 | 0.0 | 0.0 |
17655 | 2020-02-29 | US | New York | 0 | 0.0 | 0.0 |
18117 | 2020-03-01 | US | New York | 0 | 0.0 | 0.0 |
18579 | 2020-03-02 | US | New York | 0 | 0.0 | 0.0 |
19041 | 2020-03-03 | US | New York | 0 | 0.0 | 0.0 |
19503 | 2020-03-04 | US | New York | 0 | 0.0 | 0.0 |
19965 | 2020-03-05 | US | New York | 0 | 0.0 | 0.0 |
20427 | 2020-03-06 | US | New York | 0 | 0.0 | 0.0 |
20889 | 2020-03-07 | US | New York | 0 | 0.0 | 0.0 |
21351 | 2020-03-08 | US | New York | 0 | 0.0 | 0.0 |
21813 | 2020-03-09 | US | New York | 0 | 0.0 | 0.0 |
22275 | 2020-03-10 | US | New York | 173 | 0.0 | 173.0 |
22737 | 2020-03-11 | US | New York | 220 | 173.0 | 47.0 |
23199 | 2020-03-12 | US | New York | 328 | 220.0 | 108.0 |
23661 | 2020-03-13 | US | New York | 421 | 328.0 | 93.0 |
24123 | 2020-03-14 | US | New York | 523 | 421.0 | 102.0 |
24585 | 2020-03-15 | US | New York | 729 | 523.0 | 206.0 |
25047 | 2020-03-16 | US | New York | 957 | 729.0 | 228.0 |
25509 | 2020-03-17 | US | New York | 1693 | 957.0 | 736.0 |
25971 | 2020-03-18 | US | New York | 2479 | 1693.0 | 786.0 |
indexed_max_df=indexed_prev[indexed_prev.Date==indexed_prev['Date'].max()]
indexed_max_df
Date | Country | State | Active | prev_active | total_increase | |
---|---|---|---|---|---|---|
25872 | 2020-03-18 | Thailand | NaN | 169 | 135.0 | 34.0 |
25873 | 2020-03-18 | Japan | NaN | 716 | 705.0 | 11.0 |
25874 | 2020-03-18 | Singapore | NaN | 199 | 152.0 | 47.0 |
25875 | 2020-03-18 | Nepal | NaN | 0 | 0.0 | 0.0 |
25876 | 2020-03-18 | Malaysia | NaN | 728 | 622.0 | 106.0 |
... | ... | ... | ... | ... | ... | ... |
26329 | 2020-03-18 | Netherlands | Aruba | 4 | 3.0 | 1.0 |
26330 | 2020-03-18 | Zambia | NaN | 2 | 0.0 | 2.0 |
26331 | 2020-03-18 | Djibouti | NaN | 1 | 0.0 | 1.0 |
26332 | 2020-03-18 | Gambia, The | NaN | 1 | 1.0 | 0.0 |
26333 | 2020-03-18 | United Kingdom | Montserrat | 1 | 0.0 | 1.0 |
462 rows × 6 columns
indexed_max_df.sort_values('total_increase',ascending=False).head(10)
Date | Country | State | Active | prev_active | total_increase | |
---|---|---|---|---|---|---|
25883 | 2020-03-18 | Germany | NaN | 12194 | 9166.0 | 3028.0 |
25888 | 2020-03-18 | Italy | NaN | 28710 | 26062.0 | 2648.0 |
25890 | 2020-03-18 | Spain | NaN | 12206 | 10187.0 | 2019.0 |
26029 | 2020-03-18 | France | France | 8883 | 7492.0 | 1391.0 |
26027 | 2020-03-18 | Iran | NaN | 10837 | 9792.0 | 1045.0 |
25971 | 2020-03-18 | US | New York | 2479 | 1693.0 | 786.0 |
26275 | 2020-03-18 | United Kingdom | United Kingdom | 2490 | 1843.0 | 647.0 |
26312 | 2020-03-18 | Netherlands | Netherlands | 1991 | 1660.0 | 331.0 |
25903 | 2020-03-18 | Switzerland | NaN | 2985 | 2669.0 | 316.0 |
25904 | 2020-03-18 | Austria | NaN | 1633 | 1328.0 | 305.0 |
indexed_max_df.groupby('Country').sum().sort_values('total_increase',ascending=True).query("total_increase < 0").reset_index().head(10)
Country | Active | prev_active | total_increase | |
---|---|---|---|---|
0 | China | 8106 | 9030.0 | -924.0 |
1 | Korea, South | 6789 | 6832.0 | -43.0 |
2 | Iraq | 109 | 111.0 | -2.0 |
3 | Egypt | 158 | 160.0 | -2.0 |
4 | Moldova | 28 | 29.0 | -1.0 |
5 | Montenegro | 1 | 2.0 | -1.0 |
6 | Portugal | 443 | 444.0 | -1.0 |
indexed_max_df.query("Country == 'US'").sort_values('total_increase',ascending=False).head(10)
Date | Country | State | Active | prev_active | total_increase | |
---|---|---|---|---|---|---|
25971 | 2020-03-18 | US | New York | 2479 | 1693.0 | 786.0 |
25978 | 2020-03-18 | US | Florida | 307 | 210.0 | 97.0 |
25981 | 2020-03-18 | US | Texas | 170 | 109.0 | 61.0 |
26010 | 2020-03-18 | US | Louisiana | 253 | 192.0 | 61.0 |
25972 | 2020-03-18 | US | California | 738 | 680.0 | 58.0 |
25976 | 2020-03-18 | US | Georgia | 196 | 145.0 | 51.0 |
25983 | 2020-03-18 | US | Pennsylvania | 152 | 112.0 | 40.0 |
25985 | 2020-03-18 | US | Maryland | 85 | 57.0 | 28.0 |
25977 | 2020-03-18 | US | Colorado | 182 | 158.0 | 24.0 |
26000 | 2020-03-18 | US | Wisconsin | 92 | 71.0 | 21.0 |