Skip to content

BUG: Join behaved like an inner join when only one side had MultiIndex #37211

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

Closed
wants to merge 7 commits into from

Conversation

phofl
Copy link
Member

@phofl phofl commented Oct 17, 2020

We can use the regular path now, since droplevel can handle an Index. Only difference is a resorted result, because Index.join() does not preserve the order of the leading input

left = pd.Index([0, 1, 2, 1], name="b")
right = pd.Index([1, 2, 5], name="b")
print(left.join(right, how="left"))

returns

Int64Index([0, 1, 1, 2], dtype='int64', name='b')

Edit: We may be able to delete the _join_level function, if we add a level keyword to the _join_multi function to determine the overlap.

@phofl phofl added MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Oct 17, 2020
@phofl
Copy link
Member Author

phofl commented Oct 17, 2020

The change caused a few other tests to fail, which I have not run locally. All because the new result has a differently sorted index. Is this ok or do we have to figure a way out to get the old behavior?

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Nov 17, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

@phofl if you can merge master will have a look

@@ -474,6 +474,7 @@ Reshaping
- Bug in func :meth:`crosstab` when using multiple columns with ``margins=True`` and ``normalize=True`` (:issue:`35144`)
- Bug in :meth:`DataFrame.agg` with ``func={'name':<FUNC>}`` incorrectly raising ``TypeError`` when ``DataFrame.columns==['Name']`` (:issue:`36212`)
- Bug in :meth:`Series.transform` would give incorrect results or raise when the argument ``func`` was dictionary (:issue:`35811`)
- Bug in :func:`join` behaved like an inner join, when one side had a regular :class:`Index` while the other side had a :class:`MultiIndex` (:issue:`34292`)
Copy link
Contributor

Choose a reason for hiding this comment

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

move to 1.3

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

phofl added 3 commits January 2, 2021 00:30
� Conflicts:
�	doc/source/whatsnew/v1.2.0.rst
�	pandas/core/indexes/base.py
@jreback
Copy link
Contributor

jreback commented Feb 11, 2021

@phofl status here?

@simonjayhawkins
Copy link
Member

@phofl status here?

@simonjayhawkins
Copy link
Member

@phofl closing as stale. reopen when ready.

@phofl phofl deleted the 34292 branch April 27, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: left join between df with a single index and df with a multiindex produces an inner join
3 participants