Why the difference in checking for value of pd.DataFrame vs pd.Series if value in index?
Advertisements I’m working with a pandas DataFrame and I noticed a difference in behavior when using the in operator. Here’s an example to illustrate this: import pandas as pd df = pd.DataFrame({‘a’: [4, 5, 6], ‘b’: [7, 8, 9]}) print(1 in df) print(type(df)) print(1 in df["a"]) print(type(df["a"])) Output: False <class ‘pandas.core.frame.DataFrame’> True <class ‘pandas.core.series.Series’> The… Read More Why the difference in checking for value of pd.DataFrame vs pd.Series if value in index?