-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: Fix KeyError in merge on CategoricalIndex #20777
BUG: Fix KeyError in merge on CategoricalIndex #20777
Conversation
can u show. short example of what you are trying to do |
The following code raises a
I updated the title and the description |
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.
if you can fix up the formatting will have another look. pls add a whatsnew note as well. (reshaping bug fixes)
|
||
|
||
@pytest.mark.parametrize('index', | ||
[ |
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.
write like
@pytest.mark.parametrize(
'index',
[
so it is closer to the left margin, then each of the indexes can be writen more simply, also don't use the data kwarg
e.g.
```Index(['A', 'B'], name='index_col')``
name='index_col'), | ||
]) | ||
def test_merge_index_types(index): | ||
left = DataFrame( |
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.
should be a 1-liner
48c7e4b
to
7189f5a
Compare
Codecov Report
@@ Coverage Diff @@
## master #20777 +/- ##
==========================================
+ Coverage 91.81% 91.85% +0.03%
==========================================
Files 153 153
Lines 49471 49310 -161
==========================================
- Hits 45422 45292 -130
+ Misses 4049 4018 -31
Continue to review full report at Codecov.
|
b7b9124
to
a152f3e
Compare
@jreback I fixed the formatting and added a changelog entry for the bug I fixed. Since I didn't know for sure if the other change in behavior is intended I left it out for now. Can add another entry once this is settled |
thanks @fjetter nice patch! |
For categorical type indices a
KeyError
is raised when the index level is used during a merge on an index levelExample:
With this fix, the behavior of the test
test_merge_datetime_index(self, klass)
changed, though. IMHO, the behavior in this PR is more consistent since it is the same for all input types but I'm not sure what the actual behavior should be and I couldn't find a section in the documentation explaining this path.git diff upstream/master -u -- "*.py" | flake8 --diff