Reputation: 99
I have multiple series as below
import pandas as pd
ser1 = pd.Series([True, True, False, True, False], index=['John', 'Alice', 'Lisa', 'Flank', 'King'])
ser2 = pd.Series([True, False, False, False, True], index=['John', 'Alice', 'Lisa', 'Flank', 'King'])
ser3 = pd.Series([False, True, False, False, True], index=['John', 'Alice', 'Lisa', 'Flank', 'King'])
I want to calculate True number for every row, for example John has two True result Lisa got zero. Anyone know how to do this?
Upvotes: 0
Views: 36
Reputation: 323316
Let us do pd.concat
pd.concat([ser1,ser2,ser3],axis=1).sum(axis=1)
John 2
Alice 2
Lisa 0
Flank 1
King 2
dtype: int64
Upvotes: 4