Last active
July 14, 2020 11:07
-
-
Save sudevschiz/74c64cb7ac9ef22a49d0b875e3aac47e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from datetime import datetime | |
import pandas as pd | |
import numpy as np | |
# Read merged data | |
df = pd.read_csv('https://api.covid19india.org/csv/latest/raw_data.csv') | |
df.head() | |
df['Date Announced'] = pd.to_datetime(df['Date Announced']) | |
df = df[df['Date Announced'] <= '2020-04-26'] | |
df['District_Key'] = df['State code'] + "_" + df['Detected District'] | |
df['Num cases'] = pd.to_numeric(df['Num cases'], errors='coerce') | |
dis_counts = pd.pivot_table(df,values = 'Num cases', | |
index = 'District_Key', | |
columns='Current Status', | |
aggfunc = np.sum).reset_index() | |
dis_counts.rename(columns={'Hospitalized':'Confirmed'},inplace=True) | |
# Read gospel | |
url = "https://raw.githubusercontent.com/covid19india/api/gh-pages/csv/latest/districts_26apr_gospel.csv" | |
gospel = pd.read_csv(url) | |
compare = pd.merge(gospel,dis_counts,on='District_Key', suffixes=("_gospel","_v1v2")) | |
compare.fillna(0,inplace=True) | |
compare['Conf_Diff'] = compare['Confirmed_gospel'] - compare['Confirmed_v1v2'] | |
compare['Reco_Diff'] = compare['Recovered_gospel'] - compare['Recovered_v1v2'] | |
compare['Dece_Diff'] = compare['Deceased_gospel'] - compare['Deceased_v1v2'] | |
compare.to_csv("./compare_gospel_v1v2.csv",index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment