When trying to make a comparison with a PeriodIndex type object and subsequently writing a few data tests involving them I came across some confusing behavior. Any clarification on why there is a difference in the way these statements are processed would be great.
> d = {'col1': ['a','b','c'], 'col2':pd.PeriodIndex(data=['2022-01-01','2021-05-01','2020-10-01'], freq='Q')}
> tdf = pd.DataFrame.from_records(data=d)
> print(tdf.dtypes)
col1 object
col2 period[Q-DEC]
dtype: object
> print(tdf.col2[0])
2022Q1
> print(tdf.col2[0] == '2022Q1')
False
> print(tdf[tdf.col1 == 'a'].col2 == '2022Q1')
0 True
> assert tdf[tdf.col1 == 'a'].col2 == '2022Q1', 'doesnt match'
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
> assert all(tdf[tdf.col1 == 'a'].col2 == '2022Q1'), 'doesnt match'
# Passes no big deal
Accessing the same object in a different way makes the comparison go from False to True, and then wrapping the single assertion in all helps it to pass.