Python Practice › Pandas Programs › Program 4
Subtract two Series
Write a pandas program to subtract two Series.
Input
[1, 6, 9, 5], [5, 2, 4, 5]
Output
[-4, 4, 5, 0]
Approach
-.
Solution
import pandas as pda, b = pd.Series([1, 6, 9, 5]), pd.Series([5, 2, 4, 5])print((a - b).tolist())Output
[-4, 4, 5, 0]
Learn the concept
New to this topic? Read the lesson, then come back.