Search⌘ K

Find Values in a Pandas Series

Explore the methods to locate values within a pandas Series using Python. Learn how to handle string searches with str.find, interpret Boolean results, and apply operators to accurately detect the presence of specific elements in your data.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Python 3.8
import pandas as pd
heros = pd.Series(['Batman', 'Wonder Woman', 'Superman'])
if heros.str.find('Iron Man').any():
print('Wrong universe')
else:
print('DC')

Explanation

Python’s str.find documentation says the following:

“Return the lowest index in the string where substring sub is ...