Get week start date (Monday) from a date column in Python (pandas)?

Another alternative:

df['week_start'] = df['myday'].dt.to_period('W').apply(lambda r: r.start_time)

This will set ‘week_start’ to be the first Monday before the time in ‘myday’.

You can choose different week starts via anchored offsets e.g. ’W-THU’ to start the week on Thursday instead. (Thanks @Henry Ecker for that suggestion)

Leave a Comment