RustyShackleford
RustyShackleford

Reputation: 3667

How to check if all values in a boolean pandas series is of one type and apply logic based on the if condition?

I have pandas series like so:

series:

True
False
False

How do I check the series to see if all values are True or False, and apply an if condition if they are all of one type?

Something like this:

if all series.values ==False:
   do something

Edit:

changed series to test @Wen-Ben example

False
False
False

Upvotes: 0

Views: 3286

Answers (1)

BENY
BENY

Reputation: 323226

Using all

(~s).all()
Out[5]: False

As Cold mentioned

s.is_unique&(s.iloc[0]==False)

Upvotes: 3

Related Questions