Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix(snippets): keep rolling-average example compatible with Polars 2 (#11583)

Shahmir Varqhac30e5fbc75b4
diff --git a/marimo/_snippets/data/polars-1.py b/marimo/_snippets/data/polars-1.py
index 5321851c2e..a354851ce7 100644
--- a/marimo/_snippets/data/polars-1.py
+++ b/marimo/_snippets/data/polars-1.py
@@ -13,7 +13,7 @@ def __(mo):
# Polars: Rolling Averages and Z-Score Calculations
This snippet shows advanced column operations in Polars using `rolling_mean()`, `over()` aggregations,
- and type casting with the expression API.
+ and calendar expressions with the expression API.
"""
)
return
@@ -38,7 +38,7 @@ def __():
.with_columns([
pl.col('value').sum().over('category').alias('category_sum'),
pl.col('value').rolling_mean(3).alias('rolling_avg'),
- pl.col('date').dt.month().cast(pl.Categorical).alias('month'),
+ pl.col('date').dt.month().alias('month'),
((pl.col('value') - pl.col('value').mean()) /
pl.col('value').std()).alias('zscore')
])