0

I tried

df = df.loc[20000 <= df['column'] <= 100_000]

but got the error

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I thought pandas supported such notation?

What am I meant to do instead?

theonlygusti
  • 11,032
  • 11
  • 64
  • 119

1 Answers1

1
df = df.loc[(20000 <= df['column']) & (df['column'] <= 100_000)]
Filip
  • 759
  • 4
  • 17
  • [Why be verbose when you don't need to](https://stackoverflow.com/questions/76131493/how-to-filter-values-to-be-within-range-in-pandas#comment134261892_76131493)? – BigBen Apr 28 '23 at 16:34
  • @BigBen I think it makes it clearer how to chain conditions in a more general situation, since the author asked also about pandas support for "such notation". – Filip Apr 28 '23 at 16:37