Categories
Python Answers

How to filter dataframe rows if value in column is in a set list of values with Python Pandas?

Spread the love

To filter dataframe rows if value in column is in a set list of values with Python Pandas, we can use the isin method.

For instance, we write

rpt[rpt['STK_ID'].isin(stk_list)]

to call isin to get the STK_ID values that are in the stk_list list and return it.

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 *