To drop hours from a pandas datetime column and keep only the days, you can use the dt.floor()
function. Here's an example:
main.py315 chars12 lines
Output:
main.py52 chars5 lines
In the code above, we first convert the date column to a pandas datetime format using pd.to_datetime()
. Then, we use the dt.floor()
function to drop the hours and keep only the days. Finally, we assign the updated datetime column back to the original dataframe.
gistlibby LogSnag