You are on page 1of 2

PROGRAM-4

Q.Write a Pandas program to compare the elements of the two pandas series?
Ans:-

CODE PROGRAMMING Output:-


import pandas as pd Comparison
a=pd.Series([10,20,30,40]) Equal elements
b=pd.Series([5,20,30,48]) 0 False
print("Comparison") 1 True
print("Equal elements") 2 True
print(a==b) 3 False
print("Elements of A greater than B") dtype: bool
print(a>b) Elements of A greater than B
print("Elements of A less than B") 0 True

print(a<b) 1 False
2 False
3 False
dtype: bool
Elements of A less than B
0 False
1 False
2 False
3 True
dtype:bool

PROGRAM-6
Q. Write a Pandas program to add, subtract, multiple and divide two Pandas Series
Ans:- CODE PROGRAMMING
import pandas as pd Output:-
a=pd.Series([1,2,3,4]) PROGRAM-6
Q. Write a Pandas program to add, subtract, multiple and divide two Pandas Series
Ans:- CODE PROGRAMMING
import pandas as pd Output:-
a=pd.Series([1,2,3,4]) Addition
b=pd.Series([10,20,30,40]) 0 11
print("Addition") 1 22
print(a+b) 2 33
print("Subtraction") 3 44
print(a-b) dtype: int64
print("Division") Subtraction
print(a/b) 0 -9
print("Multiplication") 1 -18
print(a*b) 2 -27
3 -36
dtype: int64
Division
0 0.1
1 0.1
2 0.1
3 0.1
dtype: float64
Multiplication
0 10
1 40
2 90
3 160
dtype: float64

You might also like