Categories
Python Answers

How to filter rows of DataFrame with operator chaining with Python Pandas?

Spread the love

To filter rows of DataFrame with operator chaining with Python Pandas, we can use the data frame query method.

For instance, we write

df_filtered = df.query('a > 0 and 0 < b < 2')

to call df.query with the conditions we want for the values to return a new data frame with the filtered values.

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 *