Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow groupby aggs for StructColumns #8499

Merged
merged 2 commits into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/cudf/cudf/_lib/groupby.pyx
Expand Up @@ -136,7 +136,7 @@ cdef class GroupBy:
_LIST_AGGS if is_list_dtype(dtype)
else _STRING_AGGS if is_string_dtype(dtype)
else _CATEGORICAL_AGGS if is_categorical_dtype(dtype)
else _STRING_AGGS if is_struct_dtype(dtype)
else _STRUCT_AGGS if is_struct_dtype(dtype)
else _INTERVAL_AGGS if is_interval_dtype(dtype)
else _DECIMAL_AGGS if is_decimal_dtype(dtype)
else "ALL"
Expand Down
21 changes: 21 additions & 0 deletions python/cudf/cudf/tests/test_groupby.py
Expand Up @@ -1495,6 +1495,27 @@ def test_groupby_list_of_lists(list_agg):
)


@pytest.mark.parametrize("list_agg", [list, "collect"])
def test_groupby_list_of_structs(list_agg):
pdf = pd.DataFrame(
{
"a": [1, 1, 1, 2, 2, 2],
"b": [
{"c": "1", "d": 1},
{"c": "2", "d": 2},
{"c": "3", "d": 3},
{"c": "4", "d": 4},
{"c": "5", "d": 5},
{"c": "6", "d": 6},
],
}
)
gdf = cudf.from_pandas(pdf)

with pytest.raises(pd.core.base.DataError):
gdf.groupby("a").agg({"b": list_agg}),


@pytest.mark.parametrize("list_agg", [list, "collect"])
def test_groupby_list_single_element(list_agg):
pdf = pd.DataFrame({"a": [1, 2], "b": [3, None]})
Expand Down