I have a date column in my pandas dataframe which I convert to datetime first and then extract the year:
data[date] = pd.to_datetime(data[date])
data['year'] = pd.PeriodIndex(data[date], freq='A')
I would like to subset this based on the year, something like:
if data['year'] ==2015
But somehow that does not work. Anyone have an idea why?