Reputation: 411
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?
Upvotes: 1
Views: 65
Reputation: 863501
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
Upvotes: 1