在应用 .dt.week 计算周数时,我们如何将星期日视为一周的开始

how do we consider sunday as the start of week when applying .dt.week to calculate week number

.dt.week 函数默认将星期一视为一周的开始,但有没有办法将 星期日视为一周的开始 示例:

analysis['week no']=(analysis['Date based Discharge'].dt.week)

输出:

Date based Discharge   week no
06-10-2019              wk 40
07-10-2019              wk 41
.........               .. ..

期望的输出:

Date based Discharge   week no
06-10-2019              wk 41
07-10-2019              wk 41

您能否在获取周索引之前将每个日期向前移动一天?

例如:

(analysis['Date based Discharge'] + pd.DateOffset(1)).dt.week

我认为这应该会给出预期的结果。