Using the in Keyword to Check Whether a Value Exists in a Pandas Series

By Hemanta Sundaray on 2021-08-10

Let’s read the budget.xlsx file into a DataFrame:

import pandas as pd

budget = pd.read_excel("budget.xlsx")

budget

Output:

Budget

Let’s check whether the city Jaipur exists in the City column using the in keyword.

“Jaipur” in budget[“City”].values

True # Returns a boolean

Join the Newsletter