Skip to content
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

CLN: Implement multiindex handling for get_op_result_name #38323

Merged
merged 9 commits into from
Dec 11, 2020

Conversation

phofl
Copy link
Member

@phofl phofl commented Dec 5, 2020

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

@jbrockmendel

This would solve the inconsistency in get_op_result_name for MultiIndexes, but adds a bit more complexity here.
I think this would allow us to remove the now duplicated code in intersection

@jbrockmendel
Copy link
Member

Can we do this by overriding get_reconciled_name_object and not get_op_result_name? id like to avoid the small-but-frequent additional overhead there

@jreback
Copy link
Contributor

jreback commented Dec 7, 2020

pls merge master

…n_get_op_result_name

� Conflicts:
�	pandas/core/indexes/multi.py
�	pandas/tests/indexes/multi/test_setops.py
@phofl
Copy link
Member Author

phofl commented Dec 7, 2020

Done and Done

@@ -122,3 +122,30 @@ def _maybe_match_name(a, b):
elif b_has:
return b.name
return None


def maybe_match_names_multiindex(a, b):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you type a, b and the return

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 need to type this after moving?

@@ -93,7 +93,7 @@ def _maybe_match_name(a, b):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

would rename this to maybe_match_names

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

"""
Try to find common names to attach to the result of an operation between
a and b. Return a consensus list of names if they match at least partly
or None if they have completely different names.
Copy link
Contributor

Choose a reason for hiding this comment

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

this could just be in padnas/core/indexes/multi.py i think would be fine

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

@jbrockmendel
Copy link
Member

LGTM ex @jreback comments

@jreback
Copy link
Contributor

jreback commented Dec 8, 2020

also pls merge master

…n_get_op_result_name

� Conflicts:
�	pandas/core/indexes/multi.py
Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

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

LGTM

@jreback jreback added this to the 1.3 milestone Dec 11, 2020
@jreback
Copy link
Contributor

jreback commented Dec 11, 2020

looks good. is this user visible in any way? e.g you mention: This would solve the inconsistency in get_op_result_name for MultiIndexes

@phofl
Copy link
Member Author

phofl commented Dec 11, 2020

No, we did use rename previously which avoided this. But now we are consistent between the intersection methods

@jreback jreback merged commit 639a9c2 into pandas-dev:master Dec 11, 2020
@jreback
Copy link
Contributor

jreback commented Dec 11, 2020

thanks @phofl

@phofl phofl deleted the cln_get_op_result_name branch December 11, 2020 23:42
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
…#38323)

* CLN: Implement multiindex handling for get_op_result_name

* Change import order

* Override method

* Move import

* Remove import

* Fix merge issue

* Move methods
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