0

I am dealing with time objects saved as strings in the form 57:44.6 (second, minute, hour).I am trying to convert the column elements to datetime using pd_todatetime. There results are Nat. How can i change the format of the string to HH:MM:SS (6:44:57)before converting?

KarimZ
  • 9
  • 4
  • 1
    Does this answer your question? [Convert Pandas Column to DateTime](https://stackoverflow.com/questions/26763344/convert-pandas-column-to-datetime) – Sergey Shubin May 26 '20 at 11:59

1 Answers1

0

provide the appropriate format specifier '%S:%M.%H'. Ex:

import pandas as pd

s = pd.Series(['57:44.6'])

dts = pd.to_datetime(s, format='%S:%M.%H')
# dts
# 0   1900-01-01 06:44:57
# dtype: datetime64[ns]
FObersteiner
  • 22,500
  • 8
  • 42
  • 72