Categories
Python Answers

How to determine whether a Python Pandas Column contains a particular value?

Spread the love

To determine whether a Python Pandas Column contains a particular value, we can use the in operator.

For instance, we write

s = pd.Series(list('abc'))
1 in s

to create a series with 'a', 'b', and 'c' as its values.

And then we can check if 1 is in the series s with 1 in s.

By John Au-Yeung

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

One reply on “How to determine whether a Python Pandas Column contains a particular value?”

I am having a problem determining if a data entered field exists IN a pandas DataFrame field to copy the row to a new dataframe. Wether I use contains or is in doesn’t seem to matter.
Any advice would be appreciated. Been struggling with this for x months.

Leave a Reply

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