Get index of series where value is True

  • A+

How do I select only True values?

myindex=['a', 'b', 'c' , 'd'] myseries=pd.Series([True, True, False, True], index=myindex)  a     True b     True c    False d     True dtype: bool 

What I have tried:

myseries.where(myseries == True) 

This includes "c" while I need to return a list of a, b and d


The code myseries[myseries] returns

a    True b    True d    True dtype: bool 

If you specifically want a list of ['a', 'b', 'd'] then you can it by list(myseries[myseries].index).


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: