Home

Published

- 1 min read

truncate date to midnight in pandas column

img of truncate date to midnight in pandas column

The solution for this is noted below

truncate date to midnight in pandas column

Solution

   df['START_DATETIME'] = pd.to_datetime(df['START_DATETIME']).dt.normalize()
# -or-
df['START_DATETIME'] = pd.to_datetime(df['START_DATETIME']).dt.floor('D')

Try other methods by searching on the site. That is if this doesn’t work