In this python pandas program, we will subtract two series using pandas.
Steps to solve the program
- Import pandas library as pd.
- Create two series using pd.Series().
- Now subtract the two series using the ” – ” operator.
- Print the output.
import pandas as pd
df1 = pd.Series([1,6,9,5])
df2 = pd.Series([5,2,4,5])
print(df1-df2)
Output :
0 -4
1 4
2 5
3 0
dtype: int64