-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical File
More file actions
265 lines (195 loc) · 6.19 KB
/
Practical File
File metadata and controls
265 lines (195 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# #Question 1
# import pandas as pd
# lst=[33, 55, 65, 29,19, 23]
# ser1=pd.Series(lst)
# print(ser1)
# ser3=sum(ser1[ser1%10==3])
# print("Sum of values ending with 3:",ser3)
# ser5=sum(ser1[ser1%10==5])
# print("Sum of values ending with 5:",ser5)
# print("Final sum of values 3 and 5:",ser3+ser5)
# #Question 2
# import pandas as pd
# ser1=pd. Series (range (41,81,3))
# print ("Original Series:")
# print (ser1)
# for i in range(0,ser1.size):
# if ser1[i]%2!=0:
# ser1[i]=ser1[i]+7
# else:
# ser1[i]=ser1[i]-3
# print ("Updated Series:")
# print (ser1)
# #Question 3
# import pandas as pd
# num=[]
# for i in range(1,11):
# val =int(input("Enter Number:"))
# num. append (val)
# serl=pd.Series (num)
# #Assume if number divisible by 4
# #then change that value = 0
# for i in range(len(serl)):
# if serl[i]%4==0:
# serl[i]=0
# print (serl)
# #Question 4
# import pandas as pd
# num=int (input("Enter Series Length:"))
# lst1=[]
# for i in range (num):
# val=int (input ("Enter Value:"))
# lst1.append (val)
# serl=pd.Series(lst1)
# print (serl)
# print (serl.head(3))
# #Question 5
# import pandas as pd
# num=int (input ("Enter Series Length:"))
# lst1=[]
# for i in range (num):
# val=int (input ("Enter Value:"))
# lst1.append (val)
# serl=pd.Series(lst1)
# print (serl)
# print (serl.tail(3))
# #Question 6
# import pandas as pd
# import numpy as np
# lst1=[21, 51,71, 31,12]
# serl=pd.Series(lst1)
# print (serl)
# print (pd. Series (np.roll (serl.values,-1)))
# #Question 7
# import pandas as pd
# lst1=["Thejas", "Ujjwal", "Aaditya", "Vidhish", "Manan"]
# student=pd. DataFrame(lst1,columns=["Student_Name"])
# print (student)
# #Question 8
# import pandas as pd
# lstl=[["Kobe Bryant",45,55,61],["Lebron James",43,57,69],["Stephen Curry",63,39,59]]
# player=pd.DataFrame(lstl,columns=["Player Name", "Match1", "Match2", "Match3"])
# print (player)
# #Question 9
# import pandas as pd
# dict1={"Country Name": ["India", "Japan", "USA"],
# "capital":["New Delhi", "Tokyo", "WDC"],
# "Population (CR) ":[140,80,70]}
# df=pd.DataFrame (dict1)
# print (df)
# #Question 10
# import pandas as pd
# lst1=[["Kobe Bryant",45,55,61],["Lebron James",43,57,69],["Stephen Curry",63,39,59]]
# player=pd.DataFrame(lst1,columns=["Player Name", "Match1","Match2","Match3"])
# print (player)
# for i,j in player.iterrows():``
# print(i,j.values)
# #Question 11
# import pandas as pd
# lst1=[["Kobe Bryant",45,55,61],["Lebron James",43,57,69],["Stephen Curry",63,39,59]]
# player=pd.DataFrame(lst1,columns=["Player_Name", "Match1","Match2","Match3"])
# print (player)
# for i,j in player.iterrows():
# print(i,j["PlayerName"],j["Match2"],i["Match3"])
# #Question 12
# import pandas as pd
# lst1=[["Kobe Bryant",45,55,61],["Lebron James",43,57,69],["Stephen Curry",63,39,59]]
# player=pd.DataFrame(lst1,columns=["Player_Name","Match1", "Match2","Match3"])
# print (player)
# player ["Total_Score"]=player["Match1"]+player["Match2"]+player["Match3"]
# player ["Rank"]=player["Total_Score"].rank (ascending=0)
# print (player)
#Question 13
# import pandas as pd
# data={"Name": ["Dhoni","F. Du Plessis","Virat","Watson","Warner"],
# "Test": [494,872,325,759,859],
# "T20":[638,856,957,956,537]}
# player=pd.DataFrame (data)
# print (player)
# player.index=player.index+1 #Start index with 1
# print(" Player Name")
# print(player.Name)
# print(" Test_Runs")
# print(player.Test)
# print(" T20_Runs")
# print(player.T20)
# #Question 14
# import pandas as pd
# data1={"Name":["Du Plessis","Rahul", "Dhoni", "Warner","Sachin"],
# "ODI":[456, 987, 649, 676, 977],
# "T20":[256, 565, 233, 675, 321]}
# player=pd.DataFrame (data1)
# print(player)
# player.index=player.index+1 #Start index with 1
# print(player.loc[:, ("Name", "ODI") ])
# #Question 15
# import pandas as pd
# datab={"Name":["Virat","L.Gopal", "David Warner", "Dravid", "Jadeja"],
# "ODI":[2456,3854,5452,8677,1278],
# "Test":[1526,7563,8769,6587,2436],
# "120":[2849,4435,6748,7836,8759]}
# player=pd.DataFrame(datab)
# print(player)
# player.index=player.index+1 #Start index with 1
# print("\nMore Than 2000 in ODI")
# print(player.loc [player ["ODI"]>2000, ["Name", "ODI"]])
# print("\nLess Than 2500 in Test")
# print(player.loc [player ["Test"]<2500, ["Name","Test"]])
# print("\nMore Than 1500 in T20")
# print (player.loc[player["T20"]>1500, ["Name","T20"]])
# #Question 16
# import matplotlib.pyplot as plt
# day=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
# income=[510,350,475,580,600]
# #Q.a
# plt.title("The Weekly Income Report")
# #Q.b
# plt.xlabel ("Week Days")
# plt.ylabel("Income in Rs.")
# #Q.d,e,f
# plt.plot(day, income, label="Income",
# color="red",linestyle="dashed",marker="D")
# #Q.c
# plt.legend()
# plt.show()
# #Question 17
# import matplotlib.pyplot as plt
# month=["March", "April", "May", "June", "July", "August"]
# mask=[1500, 3500, 6500, 6700, 6000, 6800]
# sanitizer=[4400, 4500, 5500, 6000, 5600, 6300]
# hand_wash=[6500, 5000, 5800, 6300, 6200, 4500]
# plt.title("Medical Store")
# plt.xlabel("Months")
# plt.ylabel("Sale In Quantity")
# plt.plot(month,mask, label="Mask",marker="d", linewidth=3.5)
# plt.plot(month,sanitizer, label="Sanitizer",marker="o",linewidth=3.5)
# plt.plot(month,hand_wash, label="Hand Wash",marker="8",linewidth=3.5)
# plt.legend()
# plt.show()
# #Question 18
# import matplotlib.pyplot as plt
# month=["March", "April", "May", "June", "July", "August"]
# mask=[1500, 3500, 6500, 6700, 6000, 6800]
# sanitizer=[4400, 4500, 5500, 6000, 5600, 6300]
# hand_wash=[6500, 5000, 5800, 6300, 6200, 4500]
# plt.title("Medical Store")
# plt.xlabel ("Months")
# plt.ylabel ("Sale In Quantity")
# plt.subplot (2,1,1)
# plt.plot (month, sanitizer, label="Sanitizer",marker="o",
# linewidth=3.5, color="red")
# plt.legend()
# plt.subplot (2,1, 2)
# plt.plot(month,hand_wash,label="Hand Wash",marker="8",linewidth=3.5)
# plt.legend()
# plt.show()
# #Question 19
# import matplotlib.pyplot as plt
# overs=[1,2,3,4]
# runs=[6,18,10,5]
# plt.title("Bowling Records")
# plt.xlabel("Overs")
# plt.ylabel("Runs In Per Over")
# plt.bar(overs, runs, label="Bowling", width=0.7)
# plt.legend()
# plt.show()