Consider the following mwe:
import pandas as pd
from decimal import *
from datetime import date
d1={'Date':date(2016,10,24),'Value':Decimal(20)}
d2={'Date':date(2016,10,25),'Value':Decimal(10)}
d3={'Date':date(2016,9,25),'Value':Decimal(50)}
d4={'Date':date(2016,9,24),'Value':Decimal(5)}
df=pd.DataFrame([d1,d2,d3,d4])
I'm able to access the monthattribute of a single date the following way:
df.Date[0].month
Out[22]: 10
However df.Date.month does not return a vector containing all the months as I would expect. Instead it throws me an error:
AttributeError: 'Series' object has no attribute 'month'
Is there a nice way to accomplish this without having to iterate over the dataframe?