Код: Выделить всё
import polars as pl
df = pl.from_repr("""
┌──────┬──────┬──────┬──────┬──────┐
│ col1 ┆ col2 ┆ col3 ┆ col4 ┆ col5 │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 ┆ f32 │
╞══════╪══════╪══════╪══════╪══════╡
│ 3 ┆ 3 ┆ 3 ┆ null ┆ null │
│ 2 ┆ 4 ┆ 1 ┆ 5 ┆ null │
│ 4 ┆ null ┆ null ┆ null ┆ null │
│ 7 ┆ 1 ┆ null ┆ null ┆ null │
│ 1 ┆ null ┆ null ┆ null ┆ null │
│ 10 ┆ 1 ┆ null ┆ null ┆ null │
│ 7 ┆ 9 ┆ 4 ┆ null ┆ null │
└──────┴──────┴──────┴──────┴──────┘
""")
При предположении чего-то вроде Polars.rolling_apply(, window_size=2, min_ periods=1, center=False) я ожидал бы следующий результат:
Код: Выделить всё
┌──────┐
│ res │
│ --- │
│ i64 │
╞══════╡
│ 3 │
│ 3 │
│ 4 │
│ None │ #
Подробнее здесь: [url]https://stackoverflow.com/questions/77071244/polars-calculate-rolling-mode-over-multiple-columns[/url]