Skip to content
ML Academy

Feature engineering and preprocessing · insight-1122draft — in review

Pair ISO week with ISO year, because the first or last days of a year can belong to the neighbouring ISO year

Evidence type
documented fact
Difficulty
easy
Roles
Data analyst, Data scientist
Industries
retail, aviation

Summary: situation, action, reason, boundary

  1. Situation

    A week-of-year feature is combined with the calendar year to form seasonal features or group keys, and data cross the new year.

  2. Action

    Take both year and week from the ISO calendar (isocalendar), or avoid week numbers and use day-of-year offsets and holiday proximity features.

  3. Reason

    ISO 8601 assigns each date to an ISO year that may differ from its calendar year, so week one can begin in December and week 53 can contain early January.

  4. Boundary

    Weekly seasonality features, weekly aggregates and week-keyed joins in demand and traffic data.

Symptom or risk

Days in late December and early January are assigned to the wrong week group, so year-end spikes and the new-year trough smear across keys.

Exceptions

Business calendars that define their own week numbering, in which case use that calendar consistently.

Trade-offs

Weeks of year have unequal length at boundaries (partial first and last weeks), which the feature still does not model.

Pitfalls

Mixing ISO week numbers with calendar year in one column and in a group-by key.

Example

Verified with Python: 2024-12-30 falls in ISO year 2025, week 1, and 2021-01-01 falls in ISO year 2020, week 53.

Lessons and concepts

Claims and their sources