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
.
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.