AttributeError: 'Series' object has no attribute 'days'

While subtracting the dates you should use the following code.

df = pd.DataFrame([ pd.Timestamp('20010101'), pd.Timestamp('20040605') ])
(df.loc[0]-df.loc[1]).astype('timedelta64[D]')

So basically use .astype('timedelta64[D]') on the subtracted column.


DataFrame column is a Series, and for Series you need dt.accessor to calculate days (if you are using a newer Pandas version). You can see docs here

So, you need to change:

df['days'] = float(df['delta'].days)

To

df['days'] = float(df['delta'].dt.days)