Why the function weekOfYear(2019.12.31) returns 1?

Viewed 18

which week in the year does this function return? Why is the return of 2019.12.31 the first week? I have checked this function in dolphindb-help, and it says that "weekOfYear(X): For each element in X, return a number indicating which week of the year it falls in. Each week starts on Monday." So I think it is not right for the date 12.31 to return 1 right?

1 Answers

The weekOfYear in dolphindb is consistent with the rule of weekofyear in pandas, and the specific rules are as follows:

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

Related