-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Conversation
agg1 = df1.agg(aggregation) | ||
agg2 = df2.agg(aggregation) | ||
|
||
tm.assert_class_equal(agg1, agg2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define expected as a DataFrame and then use tm.assert_frame_equal. Also, this is not a groupby test, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this shouldn't be in groupby. I've made the changes and moved it to a more appropriate file.
({"a": [2, 2, 2], "b": [1, 1, 1]}, {"a": 2, "b": 1}), | ||
], | ||
) | ||
def test_unique_agg_type_is_series(test, constant): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
@phofl I've moved my test to a new file, is this a better place for it? |
"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}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the scalars in constant should be contained in lists e.g.
# result of agg
First aggregation: <class 'pandas.core.series.Series'>
a [1, 2, 3]
b [1]
dtype: object
Second aggregation: <class 'pandas.core.series.Series'>
a [2]
b [1]
dtype: object
In [3]: Series(data={"a": [1, 2, 3], "b": 1}, index=["a", "b"], dtype="object")
Out[3]:
a 2
b 1
dtype: object
In [4]: constant = {"a": [1, 2, 3], "b": 1}
In [6]: Series(data=constant, index=["a", "b"], dtype="object")
Out[6]:
a [1, 2, 3]
b 1
dtype: object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that. Either way will work, but I think you are right that it is more accurate for it to be one-element lists rather than scalars.
Thanks @srotondo (CI failure unrelated) |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.