Last active
March 17, 2020 20:06
-
-
Save santiagocasas/1c873323d399844711cc7be09adc351c to your computer and use it in GitHub Desktop.
newdataframe
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
cases_percountry = {} | |
df_dict = {} | |
for country in countries_list: | |
cou = corona_cases_df.loc[pd.IndexSlice[:, country], :].sum() | |
cases_percountry[country] = cou[cou > 0] | |
datesformat = [datetime.strptime(da, '%m/%d/%y') | |
for da in cases_percountry[country].index] | |
df_dict[country] = pd.DataFrame(cases_percountry[country], | |
columns=['Cases'], index=datesformat) | |
df_dict[country]['DayCount'] = np.arange(1, | |
cases_percountry[country].shape[0]+1) | |
print(df_dict['Italy']['Cases'][::3]) #print cases every three days | |
>>> | |
2020-01-31 2 | |
2020-02-03 2 | |
2020-02-06 2 | |
2020-02-09 3 | |
2020-02-12 3 | |
2020-02-15 3 | |
2020-02-18 3 | |
2020-02-21 20 | |
2020-02-24 229 | |
2020-02-27 655 | |
2020-03-01 1694 | |
2020-03-04 3089 | |
2020-03-07 5883 | |
2020-03-10 10149 | |
2020-03-13 17660 | |
2020-03-16 27980 | |
Name: Cases, dtype: int64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment