I have a pandas series with boolean entries. I would like to get a list of indices where the values are True.
For example the input pd.Series([True, False, True, True, False, False, False, True])
should yield the output [0,2,3,7].
I can do it with a list comprehension, but is there something cleaner or faster?
Using boolean indexing
If need a
np.arrayobject, get the.valuesUsing
np.nonzeroUsing
np.flatnonzeroUsing
np.whereUsing
np.argwhereUsing
pd.Series.indexUsing Python's built-in
filterUsing list comprehension