<jupyter_start><jupyter_text>Step 1 Use Pandas to load COVID-19 State Data Set as the dataframe.  **[Pandas](https://pandas.pydata.org/)**  **[COVID-19 State Data Set](https://www.kaggle.com/nightranger77/covid19-state-data/data)**<jupyter_code>import pandas as pd
df=pd.read_csv("COVID19_state.csv")
df.head()<jupyter_output><empty_output><jupyter_text>Step 2 Get 20 data items as sample randomly and show them.<jupyter_code>df.sample(n=20)<jupyter_output><empty_output><jupyter_text>Step 3 Show 10 data items which the Deaths are more than 100 as sample randomly.<jupyter_code>res=df[df['Deaths']>100]
res1=res.sample(n=10)
print("The states whose deaths are above 100 are :\n",res1)<jupyter_output>The states whose deaths are above 100 are :
             State  Tested  Infected  Deaths  Population  Pop Density    Gini  \
18      Louisiana   58498     12496   409.0     4645184     107.5175  0.4990   
4      California  126700     12026   276.0    39937489     256.3727  0.4899   
38   Pennsylvania   70030     10017   136.0    12820878     286.5449  0.4689   
44           Utah   63751      6110   105.0     3282115      39.9430  0.4063   
10        Georgia   26294      6383   208.0    10736059     186.6719  0.4813   
19  Massachusetts   68800     11736   216.0     6976597     894.4355  0.4786   
14       Illinois   53581     10357   243.0    12659682     228.0243  0.4810   
5        Colorado   23900      4565   126.0     5845526      56.4011  0.4586   
48      Wisconsin   87918      7591   310.0     5851754     108.0497  0.4498   
31     New Jersey   75356     34124   846.0     8936574    1215.1991  0.4813   

    ICU Beds  Income    GDP  ...  Hospitals  Health Spending  Pollution  \[...]<jupyter_text>Step 4 Sort the data by GDP and present the top 20 data items.<jupyter_code>sort_by_gdp=df.sort_values('GDP', ascending=False)
sort_by=sort_by_gdp.head(20)
print("Sorted data :\n",sort_by)<jupyter_output>Sorted data :
                    State  Tested  Infected  Deaths  Population  Pop Density  \
7   District of Columbia    6438       902    21.0      720687   11814.5410   
34              New York  283621    113704  3565.0    19440469     412.5211   
19         Massachusetts   68800     11736   216.0     6976597     894.4355   
8               Delaware    4289       593    14.0      982895     504.3073   
6            Connecticut   22029      5276   165.0     3563077     735.8689   
4             California  126700     12026   276.0    39937489     256.3727   
47            Washington    5844       461    20.0     7797095     117.3272   
0                 Alaska    5022       171     5.0      734002       1.2863   
28          North Dakota    6207       186     3.0      761723      11.0393   
50               Wyoming    8838       324     3.0      567025       5.8400   
31            New Jersey   75356     34124   846.0     8936574    1215.1991   
20              Maryland   28337     [...]<jupyter_text>Step 5 Show the simple statistical information (mean, std, min, max, quartile1, quartile2, quartile3).<jupyter_code>res1=df.min()
print("the minimum infected people of COVID-19 are :\n",res1)
res2=df.max()
print("the maximum infected people of COVID-19 are :\n",res2)
res3=df.std()
print("the std of infected people of COVID-19 are :\n",res3)
res4=df.mean()
print("the mean of infected people of COVID-19 are :\n",res4)
res5=df.quantile([0.25,0.5,0.75])
print("the quartile of infected people of COVID-19 are :\n",res5)
res6=df.describe()
print("the description of infected people of COVID-19 are :\n",res6)<jupyter_output>the minimum infected people of COVID-19 are :
 State                 Alabama
Tested                   2523
Infected                  171
Deaths                      2
Population             567025
Pop Density            1.2863
Gini                   0.4063
ICU Beds                   94
Income                  37994
GDP                     37948
Unemployment              2.2
Sex Ratio             0.88857
Smoking Rate              8.9
Flu Deaths                9.6
Respiratory Deaths       19.6
Physicians               1172
Hospitals                   7
Health Spending          5982
Pollution                 4.4
Med-Large Airports          0
Temperature              26.6
Urban                    38.7
Age 0-25                 0.26
Age 26-54                0.35
Age 55+                  0.21
dtype: object
the maximum infected people of COVID-19 are :
 State                  Wyoming
Tested                  283621
Infected                113704
Deaths                    3565
Population        [...]<jupyter_text>Step 6 Use matplotlib show 2D images about data.[Matplotlib](https://matplotlib.org/) Plot the distribution of two class (1. GDP = 58000) of COVID-19 State Data using different colors and different  marker where x-axis is the Pollution and y-axis the Mortality-rate.<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
df['Mortality-rate']=df['Deaths']/df['Population']*1000
#print("mortality rate: \n",df['Mortality-rate'])
df1=pd.DataFrame()
df2=pd.DataFrame()
df1['gdp1']=df['GDP']
df2['gdp2']=df['GDP']

df1['pollution']=df['Pollution']
df1['mortality-rate']=df['Mortality-rate']
print(df1['pollution'])
print(df1['mortality-rate'])
df1['pollution1']=df1[df1['gdp1']<58000]['pollution']
print(df1['pollution1'])
df1['mortality-rate1']=df1[df1['gdp1']<58000]['mortality-rate']
print(df1['mortality-rate1'])
df2['pollution2']=df['Pollution']
df2['mortality-rate2']=df['Mortality-rate']
print(df2['pollution2'])
print(df2['mortality-rate2'])
df2['pollution3']=df2[df2['gdp2']>=58000]['pollution2']
print(df2['pollution3'])
df2['mortality-rate3']=df2[df2['gdp2']>=58000]['mortality-rate2']
print(df2['mortality-rate3'])
colorDict = {
    'pollution1': 0,
    'mortality-rate1': 1,
    'pollution3': 2,
    'mortality-rate3':3
}

plt.xlabel('POLLUTION')
plt.ylabel('MORTALITY RATE')
plt.scatter(df1['pollution1'], df1['mortality-rate1'],  color='g', marker='*', alpha=0.6, s=100, label='GDP<58000')
plt.scatter(df2['pollution3'], df2['mortality-rate3'],  color='b', marker='.', alpha=0.6, s=100, label='GDP>=58000') 
plt.title('Scatter plot of distribution of GDP<58000 and GDP>=58000')
plt.legend()
plt.show()
import matplotlib.pyplot as plt
import numpy as np

bigGDP=df[df["GDP"]<58000]
smallGDP=df[df["GDP"]>=58000]
bigMR=bigGDP['Deaths']/bigGDP['Infected']
smallMR=smallGDP['Deaths']/smallGDP['Infected']
# x=[bigGDP['Population'],smallGDP['Population']]
# y=[bigMR,smallMR]
labelList=['GDP<58000','GDP>=58000']


fig = plt.figure() 
ax1 = fig.add_subplot(111) 

ax1.set_title('Scatter Plot') 

plt.xlabel('Pollution') 

plt.ylabel('MR') 
color=['r','b']
ax1.scatter(bigGDP['Pollution'],bigMR,c='r',marker='s',label='GDP >= 58000')
ax1.scatter(smallGDP['Pollution'],smallMR,c='b',marker='o', label='GDP < 58000')

plt.legend( loc='upper right') 
 
plt.show()<jupyter_output><empty_output><jupyter_text>Step 7 Show the proportion of three class of COVID-19 State Data using pie chart.** About the class: **  1、 Mortality-rate  2、 Mortality-rate between 0.02 and 0.03  3、Mortality-rate > 0.03<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
df4=pd.DataFrame()
df4['mr1']=df['Mortality-rate']
#print(df3['mr1'])
df4['mortality-rate12']=df4[df4['mr1']<0.02]['mr1']
print(df4['mortality-rate12'])
df4['mortality-rate22']=df4[df4['mr1']>0.03]['mr1']
print(df4['mortality-rate22'])
df4['mortality-rate32']=df4[(df4['mr1']>0.02) & (df4['mr1']<0.03)]['mr1']
print(df4['mortality-rate32'])
df4=df4.drop(columns='mr1')
plt.pie(df4.count())
plt.show();
%matplotlib inline
import matplotlib.pyplot as plt
df['MR']=df['Deaths']/df['Infected']
MR1=len(df[df['MR']<0.02]) #<0.02

MR3=len(df[df['MR']>0.03])#>0.03
MR2=len(df["MR"])-(MR3+MR1)#0.02~0.03
labels = 'MR<0.2', '0.02<=MR<=0.03', 'MR>0.03'



sizes = [MR1,MR2,MR3]
print(sizes)
print(MR1/(MR1+MR2+MR3))
print(MR2/(MR1+MR2+MR3))
print(MR3/(MR1+MR2+MR3))
colors = ['gold', 'yellowgreen', 'lightcoral']
explode = (0.1, 0, 0)  # explode 1st slice

# Plot
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=140)

plt.axis('equal')
plt.show()<jupyter_output>[18, 22, 11]
0.35294117647058826
0.43137254901960786
0.21568627450980393
{'fraction_non_alphanumeric': 0.13682165837076607, 'fraction_numerical': 0.1439844603617822, 'mean_word_length': 2.895035460992908, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '326532', 'license': 'BSL-1.0', 'n_tokens_mistral': 3698, 'n_tokens_neox': 3040, 'n_words': 657, 'path': 'Covid_eda.ipynb', 'repo_name': 'Vineelaswathi/Covid_19_eda', 'size': '8237'}