Input:
pd.Series([True, False, True, False], index=['a', 'b', 'c', 'd'])
Desired result:
['a', 'c'] # can be in pd.Series or np.array format, doesn't matter.
But I want a solution which does not store the series in a temporary variable, e.g.
s = pd.Series([True, False, True, False], index=['a', 'b', 'c', 'd'])
s[s == True].index
stores the series in s, and uses it twice.
The solution I'm looking for is like
np.where(s)
But returns the label of the true values, rather than their integer indices.
Notes:
This question is similar to this one, but more specific.