Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit 97eabbd

Browse files
committed
feat: add median() for window rolling
1 parent ebf95e3 commit 97eabbd

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

bigframes/core/window/rolling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def sum(self):
5959

6060
def mean(self):
6161
return self._apply_aggregate(agg_ops.mean_op)
62+
63+
def median(self):
64+
return self._apply_aggregate(agg_ops.median_op)
6265

6366
def var(self):
6467
return self._apply_aggregate(agg_ops.var_op)

tests/system/small/test_window.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def test_series_groupby_rolling_closed_param(rows_rolling_series, closed):
175175
pytest.param(lambda x: x.min(), id="min"),
176176
pytest.param(lambda x: x.max(), id="max"),
177177
pytest.param(lambda x: x.mean(), id="mean"),
178+
pytest.param(lambda x: x.median(), id="median"),
178179
pytest.param(lambda x: x.count(), id="count"),
179180
pytest.param(lambda x: x.std(), id="std"),
180181
pytest.param(lambda x: x.var(), id="var"),
@@ -210,6 +211,7 @@ def test_series_window_agg_ops(rows_rolling_series, windowing, agg_op):
210211
pytest.param(lambda x: x.min(), id="min"),
211212
pytest.param(lambda x: x.max(), id="max"),
212213
pytest.param(lambda x: x.mean(), id="mean"),
214+
pytest.param(lambda x: x.median(), id="median"),
213215
pytest.param(lambda x: x.count(), id="count"),
214216
pytest.param(lambda x: x.std(), id="std"),
215217
pytest.param(lambda x: x.var(), id="var"),

third_party/bigframes_vendored/pandas/core/window/rolling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def sum(self):
2121
def mean(self):
2222
"""Calculate the weighted window mean."""
2323
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
24+
25+
def median(self):
26+
"""Calculate the rolling median."""
27+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
2428

2529
def var(self):
2630
"""Calculate the weighted window variance."""

0 commit comments

Comments
 (0)