Skip to content

ENH: MultiIndex.from_product infers names from inputs if not explicitly provided #28417

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 10 commits into from
Sep 18, 2019
Merged

ENH: MultiIndex.from_product infers names from inputs if not explicitly provided #28417

merged 10 commits into from
Sep 18, 2019

Conversation

christopherzimmerman
Copy link
Contributor

@christopherzimmerman christopherzimmerman commented Sep 12, 2019

Infers names in MultiIndex.from_product and normalizes handing of names=None between from_arrays and from_product

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

@TomAugspurger TomAugspurger added this to the 1.0 milestone Sep 12, 2019
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.

tiny comment, other lgtm.

@@ -508,7 +510,9 @@ def from_product(cls, iterables, sortorder=None, names=None):
Level of sortedness (must be lexicographically sorted by that
level).
names : list / sequence of str, optional
Names for the levels in the index.
Names for the levels in the index. If not provided, these
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 add a versionadded directive here (1.0)

Copy link
Contributor Author

@christopherzimmerman christopherzimmerman Sep 12, 2019

Choose a reason for hiding this comment

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

Will do. Would it make sense to break it out into a ..versionchanged?

names : list / sequence of str, optional
    Names for the levels in the index.

    ..versionchanged 1.0

    If not explicitly provided, names will be inferred from the
    elements of iterables if an element has a name attribute

@jreback
Copy link
Contributor

jreback commented Sep 12, 2019

do we have enough testing on from_arrays for this?

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Doc formatting. Looks good otherwise.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Verified that we do have other coverage for from_arrays and input arrays with names.

@TomAugspurger TomAugspurger merged commit 645aaae into pandas-dev:master Sep 18, 2019
@TomAugspurger
Copy link
Contributor

Thanks!

@christopherzimmerman christopherzimmerman deleted the infer_names_multiindex branch September 18, 2019 17:16
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
…ly provided (pandas-dev#28417)

* Updated MultiIndex.from_product to infer names

* Respect None names in from_arrays
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
…ly provided (pandas-dev#28417)

* Updated MultiIndex.from_product to infer names

* Respect None names in from_arrays
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.

Infer names in MultiIndex.from_product if inputs have a name attribute
3 participants