Skip to content

Instantly share code, notes, and snippets.

@rvipandey
Last active June 27, 2020 08:48
Show Gist options
  • Save rvipandey/55353390649542c8c66ba7d3cef35d73 to your computer and use it in GitHub Desktop.
Save rvipandey/55353390649542c8c66ba7d3cef35d73 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.graph_objects as go
import plotly.express as px
pd.set_option('display.max_rows', None)
import datetime
from plotly.subplots import make_subplots
from scipy.optimize import curve_fit
import warnings
warnings.filterwarnings("ignore")
latest = pd.read_csv('https://api.covid19india.org/csv/latest/state_wise.csv')
state_wise_daily = pd.read_csv('https://api.covid19india.org/csv/latest/state_wise_daily.csv')
state_wise_daily = state_wise_daily.melt(id_vars=['Date', 'Status'], value_vars=state_wise_daily.columns[2:], var_name='State', value_name='Count')
state_wise_daily = state_wise_daily.pivot_table(index=['Date', 'State'], columns=['Status'], values='Count').reset_index()
state_codes = {code:state for code, state in zip(latest['State_code'], latest['State'])}
state_codes['DD'] = 'Daman and Diu'
state_wise_daily['State_Name'] = state_wise_daily['State'].map(state_codes)
state_wise_daily=state_wise_daily[state_wise_daily.State_Name!="Total"]
state_wise_daily['Date'] = pd.to_datetime(state_wise_daily['Date'], dayfirst=True)
state_wise_daily.sort_values('Date', ascending=True,inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment