<jupyter_start><jupyter_text>Reading dataset<jupyter_code>df = pd.read_csv('/kaggle/input/latest-covid19-india-statewise-data/Latest Covid-19 India Status.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Dataset datatypes information<jupyter_code>df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 36 entries, 0 to 35
Data columns (total 8 columns):
 #   Column           Non-Null Count  Dtype  
---  ------           --------------  -----  
 0   State/UTs        36 non-null     object 
 1   Total Cases      36 non-null     int64  
 2   Active           36 non-null     int64  
 3   Discharged       36 non-null     int64  
 4   Deaths           36 non-null     int64  
 5   Active Ratio     36 non-null     float64
 6   Discharge Ratio  36 non-null     float64
 7   Death Ratio      36 non-null     float64
dtypes: float64(3), int64(4), object(1)
memory usage: 2.4+ KB<jupyter_text>Summery statistics<jupyter_code>df.describe()<jupyter_output><empty_output><jupyter_text>Active cases per state<jupyter_code>df.plot(kind='bar', x='State/UTs', y='Active',color="red", figsize=(15,6),
        title="Active cases by states", ylabel="Number of active cases")
print("Active cases per states:")<jupyter_output>Active cases per states:<jupyter_text>Active vs Deaths<jupyter_code>plt.scatter(np.log(df['Active']), np.log(df['Deaths']), marker='o')
plt.title("Active VS Deaths", fontdict={'size':15,'color':'blue'})
plt.xlabel("Active cases",fontdict={'size':10,'color':'blue'})
plt.ylabel("Deaths",fontdict={'size':10,'color':'blue'})
mpl.rc('figure',figsize=(10,5))
plt.show<jupyter_output>/opt/conda/lib/python3.7/site-packages/pandas/core/arraylike.py:364: RuntimeWarning: divide by zero encountered in log
  result = getattr(ufunc, method)(*inputs, **kwargs)<jupyter_text>Corelation among each attributes<jupyter_code>df.corr()<jupyter_output><empty_output><jupyter_text>Total cases vs Discharged<jupyter_code>plt.plot(np.log(df['Total Cases']), np.log(df['Discharged']), 'b*')
plt.title("Total Cases VS Discharged",fontdict={'size':15,'color':'blue'})
plt.xlabel("Total Cases")
plt.ylabel("Discharged")
plt.show<jupyter_output><empty_output><jupyter_text>Total cases vs Deaths<jupyter_code>plt.plot(np.log(df['Total Cases']), np.log(df['Deaths']), 'ro')
plt.title("Total Cases VS Deaths",fontdict={'size':15,'color':'red'})
plt.xlabel("Total Cases")
plt.ylabel("Deaths")
plt.show<jupyter_output><empty_output><jupyter_text>Total cases vs Active<jupyter_code>plt.plot(np.log(df['Total Cases']), np.log(df['Active']), 'g*')
plt.title("Total Cases VS Active",fontdict={'size':15,'color':'green'})
plt.xlabel("Total Cases")
plt.ylabel("Active")
plt.show<jupyter_output>/opt/conda/lib/python3.7/site-packages/pandas/core/arraylike.py:364: RuntimeWarning: divide by zero encountered in log
  result = getattr(ufunc, method)(*inputs, **kwargs)<jupyter_text>Distribution of total cases<jupyter_code>total_cases= np.array(df['Total Cases'])
print(total_cases)

sns.distplot(np.log(df['Total Cases']), kde=True)
plt.title("Distribution of total cases")
plt.show<jupyter_output>[   7646 2062781   55075  608126  726045   65320 1005799   10679 1439526
  177819  826378  771133  222312  331494  348562 2985227 4897884   20896
   10365  792729 6599850  123107   83269  116689   31689 1037523  127621
  602163  954396   31842 2692949  669932   84376 1710069  343799 1584492]<jupyter_text>Comparisons of total cases with active, discharged and deaths<jupyter_code>plt.subplot(1,3,1)
plt.plot(np.log(df['Total Cases']), np.log(df['Active']), 'go')
plt.title("Active VS Total Cases ",fontdict={'size':12,'color':'green'})
plt.xlabel("Total Cases")
plt.ylabel("Active")

plt.subplot(1,3,2)
plt.plot(np.log(df['Total Cases']), np.log(df['Discharged']), 'b*')
plt.title("Discharged VS Total Cases",fontdict={'size':12,'color':'blue'})
plt.xlabel("Total Cases")
plt.ylabel("Discharged")

plt.subplot(1,3,3)
plt.plot(np.log(df['Total Cases']), np.log(df['Deaths']), 'go')
plt.title("Deaths VS Total Cases",fontdict={'size':12,'color':'red'})
plt.xlabel("Total Cases")
plt.ylabel("Deaths")

plt.tight_layout()
plt.show<jupyter_output>/opt/conda/lib/python3.7/site-packages/pandas/core/arraylike.py:364: RuntimeWarning: divide by zero encountered in log
  result = getattr(ufunc, method)(*inputs, **kwargs)<jupyter_text>Total cases per state<jupyter_code>ylabel= np.array(df['State/UTs'])

xpoints = np.array(np.log(df['Total Cases']))
print(xpoints)
print("total cases per state as of 16th october 2021:")

fig, ax = plt.subplots()

ax.barh(ylabel,xpoints, label='States/UTs', height=0.3)
ax.set_title("Total cases by states",fontdict={'size':20,'color':'blue'})
ax.set_xlabel("Total cases log base(e) of total cases",fontdict={'size':15,'color':'red'})
ax.set_ylabel("States/UTs",fontdict={'size':15,'color':'red'})
ax.legend(loc='upper right')

fig.set_size_inches(10,20)
fig.show<jupyter_output>[ 8.94193791 14.53956563 10.91645117 13.31813738 13.49536728 11.08705355
 13.82129281  9.27603448 14.17982445 12.08852146 13.62480757 13.55561614
 12.31183708 12.71136499 12.7615714  14.90918635 15.40431383  9.94731303
  9.24619002 13.5832367  15.70255748 11.72080917 11.32983161 11.66726756
 10.3637249  13.8523467  11.75682021 13.30828345 13.76883396 10.36854145
 14.80614743 13.41493149 11.34303828 14.35204428 12.74781246 14.27577441]
total cases per state as of 16th october 2021:<jupyter_text>Active, Discharged and Death cases portion<jupyter_code>tc = np.sum(df['Total Cases'])
print("total cases:",tc)
ac = np.sum(df['Active'])
print("Actice cases: ", ac)
dc = np.sum(df['Discharged'])
print("Discharged cases: ", dc)
deaths = np.sum(df['Deaths'])
print("total deaths: ", deaths)

piec = np.array([ac, dc, deaths])
lebels= ["Active","Discharged", "Deaths"]
myexplode=[0,0.2,0.2]
print(piec)

plt.pie(piec, labels=lebels, explode=myexplode)
plt.title("Active, Discharged and Death cases",fontdict={'size':20,'color':'red'})
plt.legend()
plt.show<jupyter_output>total cases: 34159562
Actice cases:  173728
Discharged cases:  33532126
total deaths:  453708
[  173728 33532126   453708]<jupyter_text>Most number of deaths among all states<jupyter_code>states = np.array(df['State/UTs'])
deaths = np.array(df['Deaths'])

ndf = pd.DataFrame({'states':states,
                    'deaths':deaths})

resetidx = ndf.set_index('states')
sorteddf = resetidx.deaths.sort_values(ascending=False).head()
print("States with most number of deaths: ",sorteddf)

sorteddf.plot(kind='bar', x='states', y='deaths',
             title='Most number of deaths among all states',
             figsize=(12,6),
             legend=True,
             xlabel="States",
             ylabel="Number of Deaths",
             fontsize=10,
             color="red",
             rot=1)
plt.show<jupyter_output>States with most number of deaths:  states
Maharashtra    139965
Karnataka       37995
Tamil Nadu      35987
Kerala          27765
Delhi           25091
Name: deaths, dtype: int64<jupyter_text>Most number of active cases among all states<jupyter_code>states = np.array(df['State/UTs'])
active = np.array(df['Active'])

ndf2 = pd.DataFrame({'states':states,
                     'active':active}, index=states)

sorted2= ndf2.active.sort_values(ascending=False).head()
print("statea with most active cases:\n",sorted2)

sorted2.plot.bar(title="Most number of active cases among all states",
                ylabel="Number of active cases",
                xlabel="States",
                figsize=(12,6),
                color="yellow",
                rot=1,
                legend=True,
                fontsize=10
                )
plt.show<jupyter_output>statea with most active cases:
 Kerala         81490
Maharashtra    27747
Tamil Nadu     13531
Mizoram         9636
Karnataka       8920
Name: active, dtype: int64<jupyter_text>Ratio of deaths per state<jupyter_code>totalcases = np.array(np.log(df['Total Cases']))
deaths = np.array(df['Deaths'])
dratio = np.array(df['Death Ratio'])*100
print(dratio)

fig, ax=plt.subplots()

ax.scatter(totalcases,deaths, s=dratio, c='red', alpha=0.5)
ax.set_xlabel("Log(e) of total cases",fontdict={'size':15,'color':'red'})
ax.set_ylabel("Deaths count",fontdict={'size':15,'color':'red'})
ax.set_title("Ratio of deaths per state",fontdict={'size':20,'color':'red'})

fig.patch.set_facecolor("grey")
fig.set_size_inches(10,6)
fig.show<jupyter_output>[169.  69.  51.  98. 133. 126. 135.   4. 174. 189. 122. 130. 168. 134.
 147. 127.  57. 100.  49. 133. 212. 155. 173.  34. 214.  80. 145. 275.
  94. 123. 134.  59.  97. 134. 215. 120.]<jupyter_text>Least number of discharged cases among each state<jupyter_code>discharged = np.array(df['Discharged'])
states = np.array(df['State/UTs'])

ddf = pd.DataFrame({'discharged':discharged,
                     'states':states}, index = states)

sortddf = ddf.discharged.sort_values(ascending=True).head()
print("least number of discharged cases among each state: ",sortddf)

sortddf.plot.bar(title="Least number of discharged cases among states",
               xlabel="States/UTs",
               ylabel="Number of discharges",
               rot=25,
               fontsize=10,
               legend=True)

plt.show<jupyter_output>least number of discharged cases among each state:  Andaman and Nicobar                          7511
Lakshadweep                                 10314
Dadra and Nagar Haveli and Daman and Diu    10671
Ladakh                                      20648
Nagaland                                    30766
Name: discharged, dtype: int64<jupyter_text>States with highest active,death and discharge case ratios<jupyter_code>states= np.array(df['State/UTs'])
ar = np.array(df['Active Ratio'])
deathr = np.array(df['Death Ratio'])
disr = np.array(df['Discharge Ratio'])

ratiodf = pd.DataFrame({'active':ar,
                       'deaths':deathr,
                       'discharge':disr}, index=states)

ratiodf.active.sort_values(ascending=False).head()
x1 =np.array(ratiodf.active.sort_values(ascending=False).head().index)
y1 =np.array(ratiodf.active.sort_values(ascending=False).head())


ratiodf.deaths.sort_values(ascending=False).head()
x2 =np.array(ratiodf.deaths.sort_values(ascending=False).head().index)
y2 =np.array(ratiodf.deaths.sort_values(ascending=False).head())


ratiodf.discharge.sort_values(ascending=False).head()
x3 =np.array(ratiodf.discharge.sort_values(ascending=False).head().index)
y3 =np.array(ratiodf.discharge.sort_values(ascending=False).head())
x3ticklabel = ['Dn&D&D','Lkshdwep','<NAME>.','Raj.','<NAME>.']

fig, (ax0,ax1,ax2) =plt.subplots(1,3)

ax0.bar(x1,y1, width=0.3)
ax0.set_title("Highest active case ratio",fontdict={'size':15,'color':'red'})
ax0.set_xlabel("States",fontdict={'size':12,'color':'red'})
ax0.set_ylabel("Case ratio",fontdict={'size':12,'color':'red'})
ax0.grid()

ax1.bar(x2,y2,width=0.3)
ax1.set_title("Highest death case ratio",fontdict={'size':15,'color':'red'})
ax1.set_xlabel("States",fontdict={'size':12,'color':'red'})
ax1.set_ylabel("Case ratio",fontdict={'size':12,'color':'red'})
ax1.grid()

ax2.bar(x3,y3,width=0.3)
ax2.set_title("HIghest discharged case ratio",fontdict={'size':15,'color':'red'})
ax2.set_xlabel("States",fontdict={'size':12,'color':'red'})
ax2.set_ylabel("Case ratio",fontdict={'size':12,'color':'red'})
ax2.set_xticklabels(x3ticklabel)
ax2.grid()

plt.suptitle("Highest case ratios",fontdict={'color':'red'}, fontsize=20)
fig.tight_layout()
fig.set_size_inches(16,8)
fig.show<jupyter_output>/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:43: UserWarning: FixedFormatter should only be used together with FixedLocator
{'fraction_non_alphanumeric': 0.1596833863890562, 'fraction_numerical': 0.08853136023401875, 'mean_word_length': 4.637245392822503, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '18', 'dir': 'jupyter-structured-clean-dedup', 'id': '471528', 'license': 'Apache-2.0', 'n_tokens_mistral': 5046, 'n_tokens_neox': 4211, 'n_words': 775, 'path': 'covid-19-india-eda-and-visualizations.ipynb', 'repo_name': 'avikumart/Covid-19-india-visulization', 'size': '11630'}