Skip to content

CLN: MultiIndex.union align with Index.union() #38423

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

Merged
merged 3 commits into from
Dec 13, 2020

Conversation

phofl
Copy link
Member

@phofl phofl commented Dec 12, 2020

  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

Similar to MultiIndex.intersection()

Stumbled over a issue in the maybe_match_names function. Can not return plain None, because MultiIndex.rename can not handle this.

cc @jbrockmendel

@@ -460,3 +460,12 @@ def test_intersection_different_names():
mi2 = MultiIndex.from_arrays([[1], [3]])
result = mi.intersection(mi2)
tm.assert_index_equal(result, mi2)


def test_union_empty_self_different_names():
Copy link
Member

Choose a reason for hiding this comment

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

any reason not to put this with the other union tests above?

Copy link
Member Author

Choose a reason for hiding this comment

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

The intersection test above is testing the Same for intersection. But we could move the union Test of course

Copy link
Member

Choose a reason for hiding this comment

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

id prefer that, but not a big deal.

dont forget to fill in the GH ref

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't have a strong preference either. Moved it up a bit.

Added the gh ref

@jbrockmendel
Copy link
Member

Can Index.union be updated to use the same code pattern?

@phofl
Copy link
Member Author

phofl commented Dec 12, 2020

We could rewrite _get_reconciled_name_object to accept the result as additional input, this would simplify a few things for us and make both cases more similar.

Edit: That is probably not that good of an idea. We are missing something like _wrap_setop_result to unify both cases

@jreback
Copy link
Contributor

jreback commented Dec 13, 2020

this looks like a bug fix no? e.g. let's add a whatsnew and merge (1.3)

@jreback jreback added this to the 1.3 milestone Dec 13, 2020
@phofl
Copy link
Member Author

phofl commented Dec 13, 2020

Only technically a bug, got in a few day ago only on master. technically because this function was only used for intersection before, which could not reach this case. So I think no need for whatsnew?

@jreback jreback merged commit 8e3e036 into pandas-dev:master Dec 13, 2020
@jreback
Copy link
Contributor

jreback commented Dec 13, 2020

thanks

@phofl phofl deleted the cln_multiIndex_union branch December 13, 2020 20:01
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
* CLN: MultiIndex.union to look like Index.union()

* Fix failing tests

* Move test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants