Spaces:
Running
Running
Henry Harbeck
commited on
Commit
·
ce78bc9
1
Parent(s):
b62cbdd
address suggestions
Browse files
polars/13_window_functions.py
CHANGED
|
@@ -103,9 +103,7 @@ def _(df, pl):
|
|
| 103 |
|
| 104 |
@app.cell(hide_code=True)
|
| 105 |
def _(mo):
|
| 106 |
-
mo.md(
|
| 107 |
-
r"""And then see what percentage of the daily total was Paid and what percentage was Organic."""
|
| 108 |
-
)
|
| 109 |
return
|
| 110 |
|
| 111 |
|
|
@@ -243,8 +241,8 @@ def _(mo):
|
|
| 243 |
|
| 244 |
@app.cell
|
| 245 |
def _(df, pl):
|
| 246 |
-
# Monday = 1, Sunday = 7
|
| 247 |
df_sorted = (
|
|
|
|
| 248 |
df.sort(pl.col("date").dt.weekday())
|
| 249 |
# Show the weekday for transparency
|
| 250 |
.with_columns(pl.col("date").dt.to_string("%a").alias("weekday"))
|
|
@@ -468,7 +466,6 @@ def _(df_sorted, pl):
|
|
| 468 |
pct_daily_revenue=(pl.col("revenue") / pl.col("revenue").sum()).over(**window),
|
| 469 |
highest_revenue_channel=pl.col("channel").top_k_by("revenue", k=1).first().over(**window),
|
| 470 |
daily_revenue_rank=pl.col("revenue").rank().over(**window),
|
| 471 |
-
cumulative_daily_revenue=pl.col("revenue").cum_sum().over(**window),
|
| 472 |
)
|
| 473 |
return
|
| 474 |
|
|
@@ -516,7 +513,7 @@ def _(mo):
|
|
| 516 |
return
|
| 517 |
|
| 518 |
|
| 519 |
-
@app.cell
|
| 520 |
def _(mo):
|
| 521 |
mo.md(
|
| 522 |
r"""
|
|
|
|
| 103 |
|
| 104 |
@app.cell(hide_code=True)
|
| 105 |
def _(mo):
|
| 106 |
+
mo.md(r"""And then see what percentage of the daily total was Paid and what percentage was Organic.""")
|
|
|
|
|
|
|
| 107 |
return
|
| 108 |
|
| 109 |
|
|
|
|
| 241 |
|
| 242 |
@app.cell
|
| 243 |
def _(df, pl):
|
|
|
|
| 244 |
df_sorted = (
|
| 245 |
+
# Monday = 1, Sunday = 7
|
| 246 |
df.sort(pl.col("date").dt.weekday())
|
| 247 |
# Show the weekday for transparency
|
| 248 |
.with_columns(pl.col("date").dt.to_string("%a").alias("weekday"))
|
|
|
|
| 466 |
pct_daily_revenue=(pl.col("revenue") / pl.col("revenue").sum()).over(**window),
|
| 467 |
highest_revenue_channel=pl.col("channel").top_k_by("revenue", k=1).first().over(**window),
|
| 468 |
daily_revenue_rank=pl.col("revenue").rank().over(**window),
|
|
|
|
| 469 |
)
|
| 470 |
return
|
| 471 |
|
|
|
|
| 513 |
return
|
| 514 |
|
| 515 |
|
| 516 |
+
@app.cell(hide_code=True)
|
| 517 |
def _(mo):
|
| 518 |
mo.md(
|
| 519 |
r"""
|