fix: Decimal values for Histogram bins (#32253)

This commit is contained in:
Michael S. Molina
2025-02-14 09:04:23 -03:00
committed by GitHub
parent fa09d8187a
commit ffe9244458
6 changed files with 112 additions and 37 deletions

View File

@@ -35,7 +35,13 @@ def test_histogram_no_groupby():
)
result = histogram(data_with_no_groupings, "a", [], bins)
assert result.shape == (1, bins)
assert result.columns.tolist() == ["1 - 2", "2 - 4", "4 - 6", "6 - 8", "8 - 10"]
assert result.columns.tolist() == [
"1.0 - 2.8",
"2.8 - 4.6",
"4.6 - 6.4",
"6.4 - 8.2",
"8.2 - 10.0",
]
assert result.values.tolist() == [[2, 2, 2, 2, 2]]
@@ -44,11 +50,11 @@ def test_histogram_with_groupby():
assert result.shape == (2, bins + 1)
assert result.columns.tolist() == [
"group",
"1 - 2",
"2 - 4",
"4 - 6",
"6 - 8",
"8 - 10",
"1.0 - 2.8",
"2.8 - 4.6",
"4.6 - 6.4",
"6.4 - 8.2",
"8.2 - 10.0",
]
assert result.values.tolist() == [["A", 2, 0, 2, 0, 2], ["B", 0, 2, 0, 2, 0]]
@@ -58,11 +64,11 @@ def test_histogram_with_groupby_and_normalize():
assert result.shape == (2, bins + 1)
assert result.columns.tolist() == [
"group",
"1 - 2",
"2 - 4",
"4 - 6",
"6 - 8",
"8 - 10",
"1.0 - 2.8",
"2.8 - 4.6",
"4.6 - 6.4",
"6.4 - 8.2",
"8.2 - 10.0",
]
assert result.values.tolist() == [
["A", 0.2, 0.0, 0.2, 0.0, 0.2],
@@ -75,11 +81,11 @@ def test_histogram_with_groupby_and_cumulative():
assert result.shape == (2, bins + 1)
assert result.columns.tolist() == [
"group",
"1 - 2",
"2 - 4",
"4 - 6",
"6 - 8",
"8 - 10",
"1.0 - 2.8",
"2.8 - 4.6",
"4.6 - 6.4",
"6.4 - 8.2",
"8.2 - 10.0",
]
assert result.values.tolist() == [["A", 2, 2, 4, 4, 6], ["B", 0, 2, 2, 4, 4]]
@@ -89,11 +95,11 @@ def test_histogram_with_groupby_and_cumulative_and_normalize():
assert result.shape == (2, bins + 1)
assert result.columns.tolist() == [
"group",
"1 - 2",
"2 - 4",
"4 - 6",
"6 - 8",
"8 - 10",
"1.0 - 2.8",
"2.8 - 4.6",
"4.6 - 6.4",
"6.4 - 8.2",
"8.2 - 10.0",
]
assert result.values.tolist() == [
[