Sometimes, we want to select rows in a DataFrame between two values, in Python Pandas.
In this article, we’ll look at how to select rows in a DataFrame between two values, in Python Pandas.
How to select rows in a DataFrame between two values, in Python Pandas?
To select rows in a DataFrame between two values, in Python Pandas, we can use the between
method.
For instance, we write
df = df[df['closing_price'].between(99, 101)]
to select closing_price
column values between 99 and 101 with
df[df['closing_price'].between(99, 101)]
Conclusion
To select rows in a DataFrame between two values, in Python Pandas, we can use the between
method.