Pandas: Group by calendar-week, then plot grouped barplots for the real datetime

前端 未结 3 1691
情书的邮戳
情书的邮戳 2021-01-30 15:05

EDIT

I found a quite nice solution and posted it below as an answer. The result will look like this:

\"ent

3条回答
  •  野性不改
    2021-01-30 15:41

    Add the week to 52 times the year, so that weeks are ordered "by year". Set the tick labels back, which might be nontrivial, to what you want.


    What you want is for the weeks to increase like so

    nth week → (n+1)th week → (n+2)th week → etc.
    

    but when you have a new year it instead falls by 51 (52 → 1).

    To offset this, note that the year increases by one. So add the year's increase multiplied by 52 and the total change will be -51 + 52 = 1 as wanted.

提交回复
热议问题