-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: groupby string dtype #52599
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
TST: groupby string dtype #52599
Conversation
pandas/tests/groupby/test_groupby.py
Outdated
grouped = df.groupby("str_col", as_index=False) | ||
avg = grouped.mean() | ||
result = avg.dtypes[0] | ||
tm.assert_equal(result, expected) |
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.
Could you instead compare the resulting DataFrame e.g.
result = df.groupby("str_col", as_index=False)
expected = DataFrame(...)
tm.assert_frame_equal(result, expected)
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.
Got it!
My bad I didn't know about assert_frame_equal
. Thanks!
I read about it here, It will compare dtypes. Sounds good 👍
Are these the required changes?
expected = DataFrame({"str_col": ["a", "b", "c",], "num_col": [1.5, 2.0, 3.0]})
expected["str_col"] = expected['str_col'].astype("string")
result=grouped.mean()
tm.assert_frame_equal(result,expected)
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.
Yes
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.
Yes
Thanks for confirming.
Thanks @srkds |
Thanks @mroeschke for the review 🙏 |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.