0

I want to know if there is a shorter way for boolean indexing in pandas? Nowadays I make like that:

s = pd.Series(...)
s[s>0]

But it becomes cumbersome when the variable has a long name or if I do not have the Series/DataFrame stored in a variable.

results_of_the_query[results_of_the_query['code'] == 200]

or

stocks.get('AAPL').intraday_quotes.loc[stocks.get('AAPL').intraday_quotes['time']='9:00']
Rubén
  • 89
  • 7

1 Answers1

2

Let us do loc

For Series

s.loc[lambda x : x >0]

For DataFrame

df.loc[lambda x : x['code']>0]
BENY
  • 317,841
  • 20
  • 164
  • 234