How object becomes datetime

there is a list of time in dt like this: 1 days 02 object, 55.000000000 object, wants to be datetime, but using pd.to_datetime (pd ["time"]). Astype (" timedelta64 [h]") + 1 is not successful, showing ValueError: Unknown string format

Mar.11,2021

the error message is ValueError: Unknown string format , so specify format:

import pandas as pd

df = pd.DataFrame(data={'time': ['1 days 02:59:45.000000000']})
df['time'] = pd.to_datetime(df['time'], format='%d days %H:%M:%S.%f').values.astype('datetime64[h]')
df

I don't know if it's what you need.

Menu