Professional Documents
Culture Documents
IP PROJECT Word File
IP PROJECT Word File
NAME : ANIRUDH
CLASS : 12TH B
ROLL NO. : 19
Q1. Write a Pandas program to convert a Python list to Panda Series.
import pandas as pd
L1 = [ 'a' , 'b' , 'c' , 'd' , 'e']
S1 = pd.Series(L1)
print ('THE SERIES IS ... \n')
print (S1)
OUTPUT :
THE SERIES IS ...
0 a
1 b
2 c
3 d
dtype: object
import pandas as pd
import numpy as np
AR1 = np.array ( [ 'a' , 'b' , 'c' , 'd' , 'e'] )
S1 = pd.Series(AR1)
print ('THE SERIES IS ... \n')
print (S1)
OUTPUT:
THE SERIES IS ...
0 a
1 b
2 c
3 d
4 e
dtype: object
Q3. Write a Pandas program to compare the elements of the two Pandas Series?
import pandas as pd
S1 = pd.Series( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] )
S2 = pd.Series( [ 10 , 20 , 2 , 40 , 50 , 60 , 70 , 80 , 90 , 10 ] )
print ( S1 == S2 )
OUTPUT:
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 True
dtype: bool
import pandas as pd
Dict = {'a': 100, 'b': 200, 'c': 300, 'd': 400, 'e': 800}
S = pd.Series ( Dict )
print ( 'Converted series:' )
print ( S )
OUTPUT:
Converted series:
a 100
b 200
c 300
d 400
e 800
dtype: int64
Q5.Write a Pandas program to add, subtract, multiple and divide two Pandas
Series
import pandas as pd S1 = pd.Series( [ 10 , 20 , 20 , 40 , 50 , 60 , 70 , 80 , 90 , 100 ] )
S2 = pd.Series( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] )
print (' ')
print ( 'MENU : ')
print ("1 ---> ADDITION " )
print ("2 ---> SUBTRACTION " )
print ("3 ---> MULTIPLICATION " )
print ("4 ---> DIVISION" )
print (' ')
n= int(input("ENTER THE NUMBER FROM THE MENU ABOVE: "))
print (' ')
if n==1:
l = S1+S2
print ("ADDITION => ")
print (' ')
print (l)
elif n==2 :
q = S1-S2
print ("SUBTRACTION => ")
print (' ')
print(q)
elif n==3 :
w = S1*S2
print("MULTIPLICATION => ")
print (' ')
print(w)
elif n==4 :
print("DIVISION => ")
print (' ')
print(S1/S2)
else :
print("PLEASE ENTER A VALID NUMBER FROM THE MENU.")
OUTPUT 1:
MENU :
1 ---> ADDITION
2 ---> SUBTRACTION
3 ---> MULTIPLICATION
4 ---> DIVISION
OUTPUT 2:
MENU :
1 ---> ADDITION
2 ---> SUBTRACTION
3 ---> MULTIPLICATION
4 ---> DIVISION
0 11
1 22
2 23
3 44
4 55
5 66
6 77
7 88
8 99
9 110
dtype: int64
OUTPUT 3:
MENU :
1 ---> ADDITION
2 ---> SUBTRACTION
3 ---> MULTIPLICATION
4 ---> DIVISION
0 9
1 18
2 17
3 36
4 45
5 54
6 63
7 72
8 81
9 90
dtype: int64
OUTPUT 4:
MENU :
1 ---> ADDITION
2 ---> SUBTRACTION
3 ---> MULTIPLICATION
4 ---> DIVISION
0 10
1 40
2 60
3 160
4 250
5 360
6 490
7 640
8 810
9 1000
OUTPUT 5:
MENU :
1 ---> ADDITION
2 ---> SUBTRACTION
3 ---> MULTIPLICATION
4 ---> DIVISION
0 10.000000
1 10.000000
2 6.666667
3 10.000000
4 10.000000
5 10.000000
6 10.000000
7 10.000000
8 10.000000
9 10.000000
dtype: float64
8:20 9:00 9:35 10:15 11:10 11:45 12:20 12:55
MON
TUE
WED
THUR
FRI