0

I have a weird format in my objectcolumn in python:

 2020-08-13-09.41.16.474284

How can i convert that column to datetime? I tried:

pd.to_datetime(df['col', format='%Y-%m-%d-%H-%M.%f')

but that leads to an error: ValueError: time data '2020-08-13-10.59.43.324747' does not match format '%Y-%m-%d-%H-%M.%f' (match)

2
  • 2
    There is typo M - pd.to_datetime(df['col', format='%Y-%m-%D.%H.%M.%f') Commented Dec 1, 2020 at 12:15
  • see my edit, the %fformat is not correct how can i fix that? Commented Dec 1, 2020 at 12:16

1 Answer 1

1

You need . for match format:

pd.to_datetime(df['col'], format='%Y-%m-%d-%H.%M.%S.%f')
Sign up to request clarification or add additional context in comments.

1 Comment

@MrFuppes Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.