[Python] Get Monday of specific numbered week of year in Pandas

Discussão em 'Python' iniciado por Stack, Setembro 1, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dataframe:

    df = pd.DataFrame({'id': [1,2,3,4,5],
    'week': [201613, 201714, 201715, 201716, 201717]})


    which looks like:

    id week
    0 1 201613
    1 2 201714
    2 3 201715
    3 4 201716
    4 5 201717


    The week column is telling the week of a particular year. For example 201613 means 13th week of 2016.

    I wish to add a new column week_timestamp which should give me the time stamp of Monday this week. it should give me something like 2016–03–28 00:00:00for 201613.

    How can I do this in pandas?

    Continue reading...

Compartilhe esta Página