Skip to content

BUG/API: index.array for RangeIndex, MultiIndex #37277

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

Open
jbrockmendel opened this issue Oct 20, 2020 · 3 comments
Open

BUG/API: index.array for RangeIndex, MultiIndex #37277

jbrockmendel opened this issue Oct 20, 2020 · 3 comments
Labels
Bug Index Related to the Index class or subclasses MultiIndex

Comments

@jbrockmendel
Copy link
Member

ATM MultiIndex.array raises ValueError, since there is no single array actually backing MI. RangeIndex creates and returns a PandasArray. I think RangeIndex should also raise (at least until/unless we implement a RangeArray).

This also has implications for extract_array, which currently raises on MultiIndex, which has led to some ugly checks in e.g. Index._cmp_method.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 20, 2020
@rhshadrach rhshadrach added the Index Related to the Index class or subclasses label Oct 22, 2020
@jbrockmendel
Copy link
Member Author

@TomAugspurger @jorisvandenbossche thoughts here on adding something like a preserve_mi=False kwarg to extract_array to return unchanged instead of raising?

@jorisvandenbossche
Copy link
Member

I don't have a strong opinion about it, but so that would basically the same as:

arr = ...

if not isinstance(arr, MultiIndex):
    arr = extract_array(arr)

So it would save one line of boiler plate in every place where it is needed

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Oct 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Index Related to the Index class or subclasses MultiIndex
Projects
None yet
Development

No branches or pull requests

5 participants