comp20008-project01/parta1.py
2021-04-09 22:46:35 +10:00

22 lines
838 B
Python

import pandas as pd
import argparse
all_covid_data = pd.read_csv('data/owid-covid-data.csv', encoding = 'ISO-8859-1')
reduced_data = all_covid_data.loc[:,['location', 'date', 'total_cases', 'new_cases', 'total_deaths', 'new_deaths']]
# reduced_data_grouped = reduced_data.groupby(['location', 'date'], as_index = False)
new_cases = all_covid_data.loc[:, ['location', 'date', 'new_cases']]
new_cases.date = pd.to_datetime(new_cases.date)
new_cases_grouped = new_cases.groupby([new_cases.date.dt.month, new_cases.location]).new_cases.sum()
new_deaths = all_covid_data.loc[:, ['location', 'date', 'new_deaths']]
new_deaths.date = pd.to_datetime(new_deaths.date)
new_deaths_grouped = new_deaths.groupby([new_deaths.date.dt.month, new_deaths.location]).new_deaths.sum()
print(new_cases_grouped)
print("\n\n")
print(new_deaths_grouped)