Pandas: Simplify filter expressions with between
You can reduce this filter:
df[(df.price >= 2) & (df.price <= 4)]
to:
df[df.price.between(2, 4)]
You can reduce this filter:
df[(df.price >= 2) & (df.price <= 4)]
to:
df[df.price.between(2, 4)]
Leave a comment