Skip to content

Add test for unique aggregation returning different dtypes #47603

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

Merged
merged 6 commits into from
Jul 26, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pandas/tests/util/test_assert_series_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,21 @@ def test_assert_series_equal_identical_na(nulls_fixture):
# while we're here do Index too
idx = pd.Index(ser)
tm.assert_index_equal(idx, idx.copy(deep=True))


@pytest.mark.parametrize(
"test, constant",
[
({"a": [1, 2, 3], "b": [1, 1, 1]}, {"a": [1, 2, 3], "b": 1}),
({"a": [2, 2, 2], "b": [1, 1, 1]}, {"a": 2, "b": 1}),
],
)
def test_unique_agg_type_is_series(test, constant):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still in the wrong place. Please check the frame folder for example. We have specific aggregations tests where this belongs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some aggregation tests for DataFrames in apply/test_frame_apply.py. Would that be an appropriate place for this test?

# GH#22558
df1 = DataFrame(test)
expected = Series(data=constant, index=["a", "b"], dtype="object")
aggregation = {"a": "unique", "b": "unique"}

result = df1.agg(aggregation)

tm.assert_series_equal(result, expected)