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 get the rows with the closing_price
column between values 99 and 101.
Conclusion
To select rows in a DataFrame between two values in Python Pandas, we can use the between
method.