I need help extracting the weekdate from my df:
df = pd.DataFrame({
'weeknum':[12,24,36,48,50],
'year':[2023,2023,2023,2023,2023]
})
my desired output is to have a new column named "weekDate" which will pull the date of the first Monday of the specific week in a "yyyy-MM-dd" format:
E.g. for Week: 12, Year: 2023 ====> "2023-03-20" (which is the first Monday of week 12 in 2023)
Many thanks in advance,
You can concatenate the columns and use
to_datetimewith the'%Y-%W-%w'format (more info here):Output: