I have some data that looks like this. I want to add a week_id
date column where the week_id
represents the Sunday that the week began. I'm super new to python (coming from R) so I would use as.Date
with the cut
function to do something like this. But all I've seen so far in python documentation is adding like a week number.
customer date
xxxx 12/1/15
xxxx 12/3/15
xxxx 12/7/15
xxxx 12/13/15
yyyy 12/14/15
yyyy 12/15/15
yyyy 12/21/15
I want the output to look like this
customer date week_id
xxxx 12/1/15 11/29/15
xxxx 12/3/15 11/29/15
xxxx 12/7/15 12/6/15
xxxx 12/13/15 12/13/15
yyyy 12/14/15 12/13/15
yyyy 12/15/15 12/13/15
yyyy 12/21/15 12/20/15