Skip to content

Commit c6e2396

Browse files
add index page
1 parent 1db2d43 commit c6e2396

File tree

6 files changed

+1018
-4
lines changed

6 files changed

+1018
-4
lines changed

data_science_tools/narwhals_row_ordering.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def _(mo):
2828
return
2929

3030

31+
@app.cell
32+
def _(mo):
33+
mo.md(r"""## Motivation""")
34+
return
35+
36+
3137
@app.cell
3238
def _():
3339
from datetime import datetime
@@ -54,6 +60,24 @@ def _():
5460
return (data,)
5561

5662

63+
@app.cell
64+
def _(data, pd):
65+
pdf = pd.DataFrame(data)
66+
pdf["sales"] = pdf.groupby("store")["sales"].ffill()
67+
pdf
68+
return
69+
70+
71+
@app.cell
72+
def _(data, pl):
73+
lazy_df = pl.DataFrame(data).lazy()
74+
lazy_df.with_columns(
75+
pl.col("sales").fill_null(strategy="forward").over("store")
76+
).collect()
77+
# ⚠️ This may not work as expected unless you specify order_by="sale_date"
78+
return
79+
80+
5781
@app.cell(hide_code=True)
5882
def _(mo):
5983
mo.md(r"""## Eager-only solution""")
@@ -90,7 +114,7 @@ def _(agnostic_ffill_by_store, data):
90114
# polars.DataFrame
91115
df_polars = pl.DataFrame(data)
92116
agnostic_ffill_by_store(df_polars)
93-
return (df_pandas,)
117+
return df_pandas, df_polars, pd, pl
94118

95119

96120
@app.cell
@@ -102,6 +126,13 @@ def _():
102126
return (duckdb_rel,)
103127

104128

129+
@app.cell
130+
def _():
131+
# agnostic_ffill_by_store(duckdb_rel)
132+
# Error: narwhals.exceptions.OrderDependentExprError: Order-dependent expressions are not supported for use in LazyFrame.
133+
return
134+
135+
105136
@app.cell(hide_code=True)
106137
def _(mo):
107138
mo.md(r"""## Eager and lazy solution""")
@@ -130,6 +161,12 @@ def _(agnostic_ffill_by_store_improved, duckdb_rel):
130161
return
131162

132163

164+
@app.cell
165+
def _(agnostic_ffill_by_store_improved, df_polars):
166+
agnostic_ffill_by_store_improved(df_polars.lazy()).collect()
167+
return
168+
169+
133170
@app.cell
134171
def _(agnostic_ffill_by_store_improved, df_pandas):
135172
# Note that it still supports pandas

export_notebook.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ uv run marimo export html "$notebook_name.py" -o "public/$notebook_name.html" --
2424
# Check if the export was successful
2525
if [ $? -eq 0 ]; then
2626
echo "Successfully exported $notebook_name.py to public/$notebook_name.html"
27+
# Generate index.html
28+
echo "Generating index.html..."
29+
uv run scripts/generate_index.py
2730
else
2831
echo "Error: Failed to export notebook"
2932
exit 1

0 commit comments

Comments
 (0)