Код: Выделить всё
agg_pivoted_df = pivoted_df.with_columns([
pl.col(col).cum_sum().alias(col) for col in pivoted_df.columns if col != "year_week"
] + [pl.col("year_week").str.replace("W", "").str.to_date("%Y%W").dt.offset_by("2d")]
)
Код: Выделить всё
InvalidOperationError: conversion from `str` to `date` failed in column 'year_week' for 45 out of 45 values: ["202351", "202511", … "202520"]
You might want to try:
- setting `strict=False` to set values that cannot be converted to `null`
- using `str.strptime`, `str.to_date`, or `str.to_datetime` and providing a format string
Я не понимаю, чего мне не хватает, чтобы фрагмент заработал. Как правильно проанализировать дату типа 2026W03 в полярах? Я использую поляры==1.37.0 и python==3.13.3
Подробнее здесь: https://stackoverflow.com/questions/798 ... per-format
Мобильная версия