-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Added test to confrim categorical perservation with merge #52810
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
|
||
def test_merge_perserve_categorical_index(): | ||
# gh37480 | ||
df1 = pd.DataFrame({'x': [i for i in range(10)], 'y': [i for i in range(10)], |
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 can do range(10)
instead of [i for i in range(10)]
'z': [i for i in range(10)], 'd': [i for i in range(10)]}) | ||
df2 = df1.astype({'x':'category', 'y':'category', 'z':'category'}) | ||
|
||
df3 = df2.iloc[:10, :].groupby(['z', 'x'], observed=True).agg({'d': 'sum'}) |
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.
Why are you doing a groupby here?
|
||
result = pd.merge(df3, df4, left_index=True, right_index=True, how='outer') | ||
|
||
assert(result.index.dtypes == 'category').all() |
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 always check the whole object with tm.assert_frame_equal()
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.