fix: Histogram chart not able to use decimal datatype column (#30416)

This commit is contained in:
Michael S. Molina
2024-09-30 09:04:55 -03:00
committed by GitHub
parent bdd50c7553
commit 4834390e6a
3 changed files with 19 additions and 24 deletions

View File

@@ -117,28 +117,20 @@ def test_histogram_with_groupby_and_cumulative_and_normalize():
def test_histogram_with_non_numeric_column():
try:
histogram(data, "b", ["group"], bins)
histogram(data, "group", None, bins)
except ValueError as e:
assert str(e) == "The column 'b' must be numeric."
assert str(e) == "Column 'group' contains non-numeric values"
# test histogram ignore null values
def test_histogram_ignore_null_values():
data_with_null = DataFrame(
def test_histogram_with_some_non_numeric_values():
data_with_non_numeric = DataFrame(
{
"group": ["A", "A", "B", "B", "A", "A", "B", "B", "A", "A"],
"a": [1, 2, 3, 4, 5, 6, 7, 8, 9, None],
"b": [1, 2, 3, 4, 5, 6, 7, 8, 9, None],
"a": [1, 2, 3, 4, 5, 6, 7, 8, 9, "10"],
"b": [1, 2, 3, 4, 5, 6, 7, 8, 9, "10"],
}
)
result = histogram(data_with_null, "a", ["group"], bins)
assert result.shape == (2, bins + 1)
assert result.columns.tolist() == [
"group",
"1 - 2",
"2 - 4",
"4 - 5",
"5 - 7",
"7 - 9",
]
assert result.values.tolist() == [["A", 2, 0, 1, 1, 1], ["B", 0, 2, 0, 1, 1]]
try:
histogram(data_with_non_numeric, "a", ["group"], bins)
except ValueError as e:
assert str(e) == "Column 'group' contains non-numeric values"