I have a dataframe with dates, and I want to make a column with only the month of the corresponding date in each row. First, I converted my dates to ts objects like this:
df['Date'] = pd.to_datetime(df['Date'])
After that, I tried to make my new column for the month like this:
df['Month'] = df['Date'].month
However, it gives me an error:
AttributeError: 'Series' object has no attribute 'month'
I do not understand why I can't do it like this. I double checked whether the conversion to ts objects actually works, and that does work. Also, if I extract 1 date using slicing, I can append .month to get the month. I technically could solve the problem by looping over all indices and then slicing for each index, but my dataframe contains 166000+ rows so that is not an option.