So my code is as follows:
df[\'Dates\'][df[\'Dates\'].index.month == 11]
I was doing a test to see if I could filter the months so it only
pd.to_datetime & dt accessorThe accepted answer is not the "pandas" way to approach this problem.
To select only rows with month 11, use the dt accessor:
# df['Date'] = pd.to_datetime(df['Date']) -- if column is not datetime yet
df = df[df['Date'].dt.month == 11]
Same works for days or years, where you can substitute dt.month with dt.day or dt.year
Besides that, there are many more, here are a few:
dt.quarterdt.weekdt.weekdaydt.day_namedt.is_month_enddt.is_month_startdt.is_year_enddt.is_year_startFor a complete list see the documentation