Categories
Python Answers

How to select rows in a DataFrame between two values, in Python Pandas?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *