2

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']))
  • 2
    https://stackoverflow.com/questions/32888124/pandas-out-of-bounds-nanosecond-timestamp-after-offset-rollforward-plus-adding-a – FloLie Jun 07 '21 at 14:37

1 Answers1

1

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"))
FloLie
  • 1,820
  • 1
  • 7
  • 19
AmineBTG
  • 597
  • 3
  • 13