Skip to content

Commit

Permalink
fix: Fix DataFrame.min/max for decimals (#14890)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrosbar authored Mar 6, 2024
1 parent 4e521e8 commit 3cf4897
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/polars-core/src/datatypes/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ impl DataType {

let phys = self.to_physical();
(phys.is_numeric()
|| self.is_decimal()
|| matches!(
phys,
DataType::Binary | DataType::String | DataType::Boolean
Expand Down
8 changes: 8 additions & 0 deletions py-polars/tests/unit/datatypes/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ def test_decimal_df_vertical_sum() -> None:
assert_frame_equal(df.sum(), expected)


def test_decimal_df_vertical_agg() -> None:
df = pl.DataFrame({"a": [D("1.0"), D("2.0"), D("3.0")]})
expected_min = pl.DataFrame({"a": [D("1.0")]})
expected_max = pl.DataFrame({"a": [D("3.0")]})
assert_frame_equal(df.min(), expected_min)
assert_frame_equal(df.max(), expected_max)


def test_decimal_in_filter() -> None:
df = pl.DataFrame(
{
Expand Down

0 comments on commit 3cf4897

Please sign in to comment.