Skip to content

Instantly share code, notes, and snippets.

View abhishek-shrm's full-sized avatar

ABHISHEK SHARMA abhishek-shrm

  • ZS Associates
  • New Delhi, India
View GitHub Profile
india_geojson.plot()
df_covid.isnull().sum()
df_covid['Date']=pd.to_datetime(df_covid['Date']).apply(lambda x: x - pd.DateOffset(days=1))
df_covid['Name of State / UT'].unique()
df_covid['Name of State / UT']=df_covid['Name of State / UT'].apply(lambda x: re.sub('Union Territory of ','',x))
df_covid['Name of State / UT'].replace('Telengana','Telangana',inplace=True)
df_covid['Name of State / UT'].replace('Dadar Nagar Haveli','Dadra and Nagar Haveli',inplace=True)
id_dict={'Andaman and Nicobar Islands': '0',
'Arunachal Pradesh': '1',
'Assam': '2',
'Bihar': '3',
'Chandigarh': '4',
'Chhattisgarh': '5',
'Dadra and Nagar Haveli': '6',
'Daman and Diu': '7',
'Goa': '8',
'Gujarat': '9',
df_covid['Active Cases']=df_covid['Total Confirmed cases']-(df_covid['Cured/Discharged/Migrated']+df_covid['Death'])
df_covid.head()
bins=np.linspace(min(df_covid['Active Cases']),max(df_covid['Active Cases']),11)
bins
# Coloring states and UTs with active COVID-19 cases
df_covid['color']=pd.cut(df_covid['Active Cases'],bins,labels=['#FFEBEB','#F8D2D4','#F2B9BE','#EBA1A8','#E58892','#DE6F7C','#D85766','#D13E50','#CB253A','#C50D24'],include_lowest=False)
# Coloring states and UTs with no active cases but previously had
df_covid['color'].replace(np.nan,'#32CD32',inplace=True)