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
| px.scatter(data2, x="totalconfirmed", y="totaldeceased", | |
| animation_frame=data2.date.astype(str), animation_group="state", | |
| size="totaltested", color="state", hover_name="state", | |
| range_x=[0,450000], range_y=[0,16000] | |
| ) |
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
| <script> | |
| // set the dimensions and margins of the graph | |
| var margin = {top: 10, right: 30, bottom: 30, left: 60}, | |
| width = 460 - margin.left - margin.right, | |
| height = 400 - margin.top - margin.bottom; | |
| // append the svg object to the body of the page | |
| var svg = d3.select("#my_dataviz") | |
| .append("svg") |
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
| monthwise = df.groupby(['district','month']).last()['confirmed'].unstack() | |
| monthwise['growth'] = monthwise[5]/monthwise[4] | |
| growth = monthwise.drop(6, axis=1)[monthwise[5]>1000].dropna(subset=['growth']) | |
| growth = growth.sort_values(by=['growth'], ascending = False) | |
| growth.rename(columns ={4: 'Last day of April', 5: 'Last day of May'}) |
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
| districts_daily = requests.get('https://api.covid19india.org/districts_daily.json') | |
| districts_daily = districts_daily.text | |
| districts_daily = json.loads(districts_daily) | |
| states = []; districts = []; dates = []; active = []; confirmed = [] | |
| deceased = []; recovered = [] | |
| for state in districts_daily["districtsDaily"]: | |
| for district in districts_daily["districtsDaily"][state]: | |
| for day in districts_daily["districtsDaily"][state][district]: | |
| states.append(state) | |
| districts.append(district) |
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
| stateslist = ['Maharashtra', 'Gujarat', 'Delhi', 'Karnataka', 'Kerala', 'West Bengal'] | |
| for state in stateslist: | |
| statedata = data[data['state']==state] | |
| plt.plot(statedata['Dates'][-15:], statedata['dailytested'][-15:], label=state) | |
| plt.title('Daily Tests ') | |
| plt.legend() | |
| plt.show() |
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
| stateslist = ['Maharashtra', 'Gujarat', 'Delhi', 'Karnataka', 'Kerala', 'West Bengal'] | |
| for state in stateslist: | |
| statedata = data[data['state']==state] | |
| plt.plot(statedata['Dates'], statedata['positive']/statedata['totaltested'], label=state) | |
| plt.title('Test Positive Rate: Cumulative cases/Total tests ') | |
| plt.legend() | |
| plt.show() |
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
| data = data.sort_values(by=['state', 'Dates']) | |
| data['dailypositive'] = data['positive'].diff() | |
| data['dailytested'] = data['totaltested'].diff() | |
| data.loc[data['state']!=data['state'].shift(1), 'dailytested'] = data['totaltested'] | |
| data.loc[data['state']!=data['state'].shift(1), 'dailypositive'] = data['positive'] |
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
| data['Dates']= pandas.to_datetime(data['Dates'], format = '%d/%m/%Y') | |
| data.loc[data['positive']=='','positive'] = None | |
| data['positive'] =data['positive'].fillna(method='ffill') | |
| data['positive'] = data['positive'].astype(int) | |
| data.loc[data['totaltested']=='','totaltested'] = None | |
| data['totaltested'] =data['totaltested'].fillna(method='ffill') | |
| data['totaltested'] = data['totaltested'].astype(int) |
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
| states = [] | |
| totaltested= [] | |
| positive = [] | |
| dates= [] | |
| for state in state_json_data['states_tested_data']: | |
| states.append(state['state']) | |
| totaltested.append(state['totaltested']) | |
| positive.append(state['positive']) | |
| dates.append(state['updatedon']) |
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
| import requests | |
| import pandas | |
| import matplotlib.pyplot as plt | |
| import json | |
| html = requests.get('https://api.covid19india.org/state_test_data.json') | |
| state_json_data = json.loads(html.text) |