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