I am attempting to calculate the difference in days between todays and a pandas data consisting of historical data. Below is the intended code:
df['diff'] = pd.to_datetime( df['date']) - pd.datetime.now().date()
However, it produces the following error:
TypeError: unsupported operand type(s) for -: 'DatetimeIndex' and 'datetime.date'
The date column in the pandas table looks like this:
0 2018-12-18
1 2018-12-18
2 2018-12-18
3 2018-12-18
4 2018-12-18
How do I fix this error. Thanks in advance.