0

How do I convert the datatype of a column from integer to timedelta days format? I tried doing it but got the following error.

new_monthly5['APPROVED LEAVES'] = new_monthly5['APPROVED 
LEAVES']+timedelta(days=1)

TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'Timedelta'

Also, I tried it another way but still it didn't work.

pd.to_timedelta(new_monthly5['APPROVED LEAVES'], unit='D')

1 Answers1

1

"Timedelta" or "Timedelta days" are not type formats. You need to convert your column to "datetime" first. Then you can use datetime.timedelta command to add or substract time. Use pd.to_datetime with unit='s' if the integer data are unix time.