Skip to content
Advertisement

How to round dates to week starts in Pandas [duplicate]

I’m having a DataFrame with a date column. How can I map each date d to the start day of the week containing d?

Advertisement

Answer

import pandas as pd
df['Date'] - pd.to_timedelta(df['Date'].dt.dayofweek, unit='d')
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement