1

I need to delete dot and digits after dot in pandas datetime colums:

0   2020-01-05 21:58:15.030099
1   2020-01-09 09:15:01.286888

I write this code, but the result is the same (digits after dot):

ret.reg_dt = pd.to_datetime(ret.reg_dt, format='%Y-%m-%d %H:%M:%S')

How can I delete it?

1 Answer 1

1

You can use Series.dt.floor by seconds:

ret.reg_dt = ret.reg_dt.dt.floor('S')
print (ret)
               reg_dt
0 2020-01-05 21:58:15
1 2020-01-09 09:15:01
Sign up to request clarification or add additional context in comments.

Comments

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.