Created
August 1, 2020 17:39
-
-
Save rohitrajiit/e70196dea71209b7fb64b5c029bf90fe to your computer and use it in GitHub Desktop.
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
import plotly.graph_objects as go | |
import requests | |
import pandas | |
import json | |
districts_daily = requests.get('https://api.covid19india.org/data.json') | |
districts_daily = districts_daily.text | |
districts_daily = json.loads(districts_daily) | |
totalactive = [] | |
totalrecovered = [] | |
totaldeceased = [] | |
dailyactive = [] | |
dailyrecovered = [] | |
dailydeceased = [] | |
date = [] | |
for data in districts_daily['cases_time_series']: | |
dailyactive.append(data['dailyconfirmed']) | |
dailyrecovered.append(data['dailyrecovered']) | |
dailydeceased.append(data['dailydeceased']) | |
totalactive.append(data['totalconfirmed']) | |
totalrecovered.append(data['totalrecovered']) | |
totaldeceased.append(data['totaldeceased']) | |
date.append(data['date']) | |
df = pandas.DataFrame({'dailyactive': dailyactive, 'dailyrecovered': dailyrecovered, 'dailydeceased': dailydeceased, | |
'totalactive': totalactive, 'totaldeceased': totaldeceased, 'totalrecovered': totalrecovered, | |
'date': date}) | |
df['date'] = df['date'].str.strip() | |
df['date'] = pandas.to_datetime(df['date'] + ' 2020', format = '%d %B %Y') | |
df['totalactive'] = df['totalactive'].astype(int) | |
df['totalrecovered'] = df['totalrecovered'].astype(int) | |
df['totaldeceased'] = df['totaldeceased'].astype(int) | |
df['dailyactive'] = df['dailyactive'].astype(int) | |
df['dailyrecovered'] = df['dailyrecovered'].astype(int) | |
df['dailydeceased'] = df['dailydeceased'].astype(int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment