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?

1
  • 3
    df.loc[df['column'].between(1,10)], you can't chain series as native python like that Commented Apr 28, 2023 at 16:25

1 Answer 1

1
df = df.loc[(20000 <= df['column']) & (df['column'] <= 100_000)]
Sign up to request clarification or add additional context in comments.

2 Comments

@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".