How to convert data in pandas? (0021- to 2021)

Viewed 65

I'm try get the number of days between a date and today but I had the following error "Out of bounds nanosecond timestamp".

new['DME']
0    0021-06-09 00:00:00
1    0021-06-09 00:00:00
2    0021-06-10 00:00:00
3    0021-06-09 00:00:00
4    0021-06-09 00:00:00
5    0021-06-09 00:00:00

today = datetime.datetime.today().strftime ('%Y-%d-%m')
new['Days'] = (pd.to_datetime(today) - pd.to_datetime(new['DME']))
1 Answers

You can simmply do:

from datetime import datetime
new['Days'] = (datetime.today() - pd.to_datetime(new['DME'], format=("00%y-%m-%d %H:%M:%S"))
Related