weekOfYear(2019.12.31)为什么返回1

weekOfYear这个函数是返回这一天是在本年的哪一周,为什么2019.12.31号返回是第1周?

请先 登录 后评论

1 个回答

naxi

你好,weekOfYear和pandas.Timestamp.weekofyear规则保持一致,具体规则如下:

如果12月31日是星期一、星期二或星期三,则是下一年的第01周。如果是在星期四,那是在刚刚结束的一年的第53周;如果星期五是第52周(如果刚刚结束的一年是闰年,则是第53周);如果是在周六或周日,则是在一年中刚刚结束的第52周。

If 31 December is on a Monday, Tuesday or Wednesday, it is in week 01 of the next year. If it is on a Thursday, it is in week 53 of the year just ending; if on a Friday it is in week 52 (or 53 if the year just ending is a leap year); if on a Saturday or Sunday, it is in week 52 of the year just ending.

请先 登录 后评论
  • 1 关注
  • 0 收藏,1203 浏览
  • YcHan韩迎春 提出于 2021-09-29 16:41

相似问题