pythonpandastimestampdatetime64

Timestamp datetime64 to datetime in dataframe


I am confused with datetime64 and trying convert it to a normal time format.

I have a column with timestamp format: 2022.01.02D23:10:12.197164900.

Output expected is: 2022-01-02 23:10:12

I'm trying with:

df['executionTime'] = pd.to_datetime(df['executionTime'], format='%Y-%m-%d %H:%M:%S.%f', errors='coerce')

Solution

  • Try this:

    df['executionTime'] = pd.to_datetime(df['executionTime'], format='%Y.%m.%dD%H:%M:%S.%f', errors='coerce')