Tayyab Vohra
Tayyab Vohra

Reputation: 1672

python isnull() or isna() both are not working

I am trying to find the values with condition based on column values having values 'Y' or 'N' which is working fine and i am also checking other columns having date values in which isnull() or isna() not working , I have also tried with isnull().any() or isna().any() or empty they are not working

I am getting the error

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

this is my dataframe

enter image description here

this is my code

filteringst=st.loc[(st['Passout'] =='Y') and  (st['Passout Date'].isna().any())]

I have also tried like this

filteringst=st.loc[(st['Passout'] =='Y') and  (st['Passout Date'].isnull().any())]

or

filteringst=st.loc[(st['Passout'] =='Y') and  (st['Passout Date'].isnull())]

But getting the same error

Upvotes: 0

Views: 1685

Answers (1)

jezrael
jezrael

Reputation: 862791

Use & for bitwise AND:

filteringst=st.loc[(st['Passout'] =='Y') & (st['Passout Date'].isnull())]

Upvotes: 2

Related Questions