0% found this document useful (0 votes)
10 views

Jupyter Notebook2

Uploaded by

RamRakh Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Jupyter Notebook2

Uploaded by

RamRakh Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Data Handling

In [2]: import pandas as pd #Import Pandas Library

In [3]: d1=pd.read_csv("Countrywise_coviddata.csv")
print(d1.head())

Country/Region Confirmed Deaths Recovered Active New cases New deaths


\
0 Afghanistan 36263 1269 25198 9796 106 10
1 Albania 4880 144 2745 1991 117 6
2 Algeria 27973 1163 18837 7973 616 8
3 Andorra 907 52 803 52 10 0
4 Angola 950 41 242 667 18 1

New recovered Deaths / 100 Cases Recovered / 100 Cases \


0 18 3.50 69.49
1 63 2.95 56.25
2 749 4.16 67.34
3 0 5.73 88.53
4 0 4.32 25.47

Deaths / 100 Recovered Confirmed last week 1 week change \


0 5.04 35526 737
1 5.25 4171 709
2 6.17 23691 4282
3 6.48 884 23
4 16.94 749 201

1 week % increase WHO Region


0 2.07 Eastern Mediterranean
1 17.00 Europe
2 18.07 Africa
3 2.60 Europe
4 26.84 Africa
In [5]: print (d1.head(11)) #prints the mentioned number o

Country/Region Confirmed Deaths Recovered Active New cases \


0 Afghanistan 36263 1269 25198 9796 106
1 Albania 4880 144 2745 1991 117
2 Algeria 27973 1163 18837 7973 616
3 Andorra 907 52 803 52 10
4 Angola 950 41 242 667 18
5 Antigua and Barbuda 86 3 65 18 4
6 Argentina 167416 3059 72575 91782 4890
7 Armenia 37390 711 26665 10014 73
8 Australia 15303 167 9311 5825 368
9 Austria 20558 713 18246 1599 86
10 Azerbaijan 30446 423 23242 6781 396

New deaths New recovered Deaths / 100 Cases Recovered / 100 Cases \
0 10 18 3.50 69.49
1 6 63 2.95 56.25
2 8 749 4.16 67.34
3 0 0 5.73 88.53
4 1 0 4.32 25.47
5 0 5 3.49 75.58
6 120 2057 1.83 43.35
7 6 187 1.90 71.32
8 6 137 1.09 60.84
9 1 37 3.47 88.75
10 6 558 1.39 76.34

Deaths / 100 Recovered Confirmed last week 1 week change \


0 5.04 35526 737
1 5.25 4171 709
2 6.17 23691 4282
3 6.48 884 23
4 16.94 749 201
5 4.62 76 10
6 4.21 130774 36642
7 2.67 34981 2409
8 1.79 12428 2875
9 3.91 19743 815
10 1.82 27890 2556

1 week % increase WHO Region


0 2.07 Eastern Mediterranean
1 17.00 Europe
2 18.07 Africa
3 2.60 Europe
4 26.84 Africa
5 13.16 Americas
6 28.02 Americas
7 6.89 Europe
8 23.13 Western Pacific
9 4.13 Europe
10 9.16 Europe
In [6]: print (d1.tail()) #prints last 5 re

Country/Region Confirmed Deaths Recovered Active New cases \


182 West Bank and Gaza 10621 78 3752 6791 152
183 Western Sahara 10 1 8 1 0
184 Yemen 1691 483 833 375 10
185 Zambia 4552 140 2815 1597 71
186 Zimbabwe 2704 36 542 2126 192

New deaths New recovered Deaths / 100 Cases Recovered / 100 Cases \
182 2 0 0.73 35.33
183 0 0 10.00 80.00
184 4 36 28.56 49.26
185 1 465 3.08 61.84
186 2 24 1.33 20.04

Deaths / 100 Recovered Confirmed last week 1 week change \


182 2.08 8916 1705
183 12.50 10 0
184 57.98 1619 72
185 4.97 3326 1226
186 6.64 1713 991

1 week % increase WHO Region


182 19.12 Eastern Mediterranean
183 0.00 Africa
184 4.45 Eastern Mediterranean
185 36.86 Africa
186 57.85 Africa

In [7]: d1.shape #Display size of

Out[7]: (187, 15)

In [8]: d1.dtypes #Display datatyp

Out[8]: Country/Region object


Confirmed int64
Deaths int64
Recovered int64
Active int64
New cases int64
New deaths int64
New recovered int64
Deaths / 100 Cases float64
Recovered / 100 Cases float64
Deaths / 100 Recovered float64
Confirmed last week int64
1 week change int64
1 week % increase float64
WHO Region object
dtype: object
In [9]: d2=d1.sort_values(by="Deaths", ascending=False)
print(d2.head(10)) #ascending=True(Ascending

Country/Region Confirmed Deaths Recovered Active New cases \


173 US 4290259 148011 1325804 2816444 56336
23 Brazil 2442375 87618 1846641 508116 23284
177 United Kingdom 301708 45844 1437 254427 688
111 Mexico 395489 44022 303810 47657 4973
85 Italy 246286 35112 198593 12581 168
79 India 1480073 33408 951166 495499 44457
61 France 220352 30212 81212 108928 2551
157 Spain 272421 28432 150376 93613 0
132 Peru 389717 18418 272547 98752 13756
81 Iran 293606 15912 255144 22550 2434

New deaths New recovered Deaths / 100 Cases Recovered / 100 Cases \
173 1076 27941 3.45 30.90
23 614 33728 3.59 75.61
177 7 3 15.19 0.48
111 342 8588 11.13 76.82
85 5 147 14.26 80.64
79 637 33598 2.26 64.26
61 17 267 13.71 36.86
157 0 0 10.44 55.20
132 575 4697 4.73 69.93
81 212 1931 5.42 86.90

Deaths / 100 Recovered Confirmed last week 1 week change \


173 11.16 3834677 455582
23 4.74 2118646 323729
177 3190.26 296944 4764
111 14.49 349396 46093
85 17.68 244624 1662
79 3.51 1155338 324735
61 37.20 214023 6329
157 18.91 264836 7585
132 6.76 357681 32036
81 6.24 276202 17404

1 week % increase WHO Region


173 11.88 Americas
23 15.28 Americas
177 1.60 Europe
111 13.19 Americas
85 0.68 Europe
79 28.11 South-East Asia
61 2.96 Europe
157 2.86 Europe
132 8.96 Americas
81 6.30 Eastern Mediterranean
In [10]: d3=d1.drop(["Deaths","Confirmed","Active"], axis=1)
print(d3.head())

Country/Region Recovered New cases New deaths New recovered \


0 Afghanistan 25198 106 10 18
1 Albania 2745 117 6 63
2 Algeria 18837 616 8 749
3 Andorra 803 10 0 0
4 Angola 242 18 1 0

Deaths / 100 Cases Recovered / 100 Cases Deaths / 100 Recovered \


0 3.50 69.49 5.04
1 2.95 56.25 5.25
2 4.16 67.34 6.17
3 5.73 88.53 6.48
4 4.32 25.47 16.94

Confirmed last week 1 week change 1 week % increase \


0 35526 737 2.07
1 4171 709 17.00
2 23691 4282 18.07
3 884 23 2.60
4 749 201 26.84

WHO Region
0 Eastern Mediterranean
1 Europe
2 Africa
3 Europe
4 Africa

In [11]: d3.shape

Out[11]: (187, 12)


In [12]: d1.describe #describe

Out[12]: <bound method NDFrame.describe of Country/Region Confirmed Deaths


Recovered Active New cases \
0 Afghanistan 36263 1269 25198 9796 106
1 Albania 4880 144 2745 1991 117
2 Algeria 27973 1163 18837 7973 616
3 Andorra 907 52 803 52 10
4 Angola 950 41 242 667 18
.. ... ... ... ... ... ...
182 West Bank and Gaza 10621 78 3752 6791 152
183 Western Sahara 10 1 8 1 0
184 Yemen 1691 483 833 375 10
185 Zambia 4552 140 2815 1597 71
186 Zimbabwe 2704 36 542 2126 192

New deaths New recovered Deaths / 100 Cases Recovered / 100 Cases \
0 10 18 3.50 69.49
1 6 63 2.95 56.25
2 8 749 4.16 67.34
3 0 0 5.73 88.53
4 1 0 4.32 25.47
.. ... ... ... ...
182 2 0 0.73 35.33
183 0 0 10.00 80.00
184 4 36 28.56 49.26
185 1 465 3.08 61.84
186 2 24 1.33 20.04

Deaths / 100 Recovered Confirmed last week 1 week change \


0 5.04 35526 737
1 5.25 4171 709
2 6.17 23691 4282
3 6.48 884 23
4 16.94 749 201
.. ... ... ...
182 2.08 8916 1705
183 12.50 10 0
184 57.98 1619 72
185 4.97 3326 1226
186 6.64 1713 991

1 week % increase WHO Region


0 2.07 Eastern Mediterranean
1 17.00 Europe
2 18.07 Africa
3 2.60 Europe
4 26.84 Africa
.. ... ...
182 19.12 Eastern Mediterranean
183 0.00 Africa
184 4.45 Eastern Mediterranean
185 36.86 Africa
186 57.85 Africa

[187 rows x 15 columns]>


In [13]: #Isolate a column
d1["Recovered"]

Out[13]: 0 25198
1 2745
2 18837
3 803
4 242
...
182 3752
183 8
184 833
185 2815
186 542
Name: Recovered, Length: 187, dtype: int64

In [14]: #Isolate multiple columns


d1[["Deaths","Confirmed","Active"]]

Out[14]: Deaths Confirmed Active

0 1269 36263 9796

1 144 4880 1991

2 1163 27973 7973

3 52 907 52

4 41 950 667

... ... ... ...

182 78 10621 6791

183 1 10 1

184 483 1691 375

185 140 4552 1597

186 36 2704 2126

187 rows × 3 columns


In [16]: #Isolate rows
d1[4:10]

Out[16]: Deaths Re
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases

4 Angola 950 41 242 667 18 1 0 4.32

Antigua and
5 86 3 65 18 4 0 5 3.49
Barbuda

6 Argentina 167416 3059 72575 91782 4890 120 2057 1.83

7 Armenia 37390 711 26665 10014 73 6 187 1.90

8 Australia 15303 167 9311 5825 368 6 137 1.09

9 Austria 20558 713 18246 1599 86 1 37 3.47

Data Visualisation
In [19]: import matplotlib.pyplot as plt
import numpy as np
In [25]: #Bar Plot
x=np.array(["Siddhi","Manvi","Sanvi","Jhanvi","Himanshi"])
y=np.array([188,198,300,270,283])
plt.bar(x,y)
plt.show()
In [26]: #Bar Plot
x=np.array(["Siddhi","Manvi","Sanvi","Jhanvi","Himanshi"])
y=np.array([188,198,300,270,283])
plt.bar(x,y,color=["violet","magenta","blue","red","orange"],edgecolor=['black
plt.title("Result")
plt.xlabel("Name of Students")
plt.ylabel("Marks")
plt.show()
In [27]: #Scatter Plot
x=np.array(["Siddhi","Manvi","Sanvi","Jhanvi","Himanshi"])
y=np.array([188,198,300,270,283])
plt.scatter(x,y)
plt.show()
In [28]: #Line Plot
x=np.array(["Siddhi","Manvi","Sanvi","Jhanvi","Himanshi"])
y=np.array([188,198,300,270,283])
plt.plot(x,y)
plt.show()
In [39]: #Line Plot
x = np.array(["Siddhi", "Manvi", "Sanvi", "Jhanvi", "Himanshi"])
y = np.array([188, 198, 300, 270, 283])

plt.plot(x, y, marker="o", ms=12, mec="green", mfc="black", linewidth=8)


plt.title("Result")
plt.xlabel("Name of Students")
plt.ylabel("Marks")
plt.show()
In [47]: #Pie Chart

m=np.array(["Siddhi", "Manvi", "Sanvi", "Jhanvi", "Himanshi"])


n=np.array([188, 198, 300, 270, 283])
plt.pie(y,labels=x)
plt.show()
In [50]: #Histogram
a=[10,33,45,98,19,65,45,78,81,62,59,9,18,23]
plt.hist(a)
plt.show()

You might also like