Skip to content

Commit

Permalink
update test results with temporal mean
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Jan 21, 2024
1 parent 137dca6 commit 021d358
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
5 changes: 4 additions & 1 deletion py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,10 @@ def describe(
│ max ┆ cc │
└────────────┴───────┘
"""
stats = self.to_frame().describe(percentiles=percentiles)
stats = self.to_frame().describe(
percentiles=percentiles,
interpolation=interpolation,
)
stats.columns = ["statistic", "value"]
return stats.filter(F.col("value").is_not_null())

Expand Down
6 changes: 3 additions & 3 deletions py-polars/tests/unit/dataframe/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_df_describe() -> None:
"f": [
"3",
"0",
None,
"2021-07-03 07:20:00",
None,
"2020-01-01 10:30:00",
"2021-07-05 15:00:00",
Expand All @@ -69,7 +69,7 @@ def test_df_describe() -> None:
"g": [
"3",
"0",
None,
"2021-07-02",
None,
"2020-01-01",
"2021-07-05",
Expand All @@ -80,7 +80,7 @@ def test_df_describe() -> None:
"h": [
"3",
"0",
None,
"15:20:00",
None,
"10:30:00",
"15:00:00",
Expand Down
15 changes: 8 additions & 7 deletions py-polars/tests/unit/series/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ def test_series_describe_boolean() -> None:


def test_series_describe_date() -> None:
s = pl.Series([date(2021, 1, 1), date(2021, 1, 2), date(2021, 1, 3)])
result = s.describe()
s = pl.Series([date(1999, 12, 31), date(2011, 3, 11), date(2021, 1, 18)])
result = s.describe(interpolation="linear")

stats = {
"count": "3",
"null_count": "0",
"min": "2021-01-01",
"25%": "2021-01-02",
"50%": "2021-01-02",
"75%": "2021-01-03",
"max": "2021-01-03",
"mean": "2010-09-29",
"min": "1999-12-31",
"25%": "2005-08-05",
"50%": "2011-03-11",
"75%": "2016-02-13",
"max": "2021-01-18",
}
expected = pl.DataFrame({"statistic": stats.keys(), "value": stats.values()})
assert_frame_equal(expected, result)
Expand Down

0 comments on commit 021d358

Please sign in to comment.