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

Renaming an empty MultiIndex fails #14139

Closed
chazmo03 opened this issue Sep 2, 2016 · 1 comment
Closed

Renaming an empty MultiIndex fails #14139

chazmo03 opened this issue Sep 2, 2016 · 1 comment
Labels
Bug Duplicate Report Duplicate issue or pull request MultiIndex

Comments

@chazmo03
Copy link

chazmo03 commented Sep 2, 2016

s = pd.Series([0], index=pd.MultiIndex.from_tuples([('a', 1)]))

# This works:
s.rename(lambda x: x)

# This fails:
s.iloc[0:0].rename(lambda x: x)

Renaming an empty index should not throw an error. It should just return the original empty index. It appears to be failing because _transform_index calls MultiIndex.from_tuples, which doesn't accept an empty list of tuples.

I would imagine that this could instead call from_arrays, which from_tuples calls anyway, or it could check for the special case of an empty index.

@jreback
Copy link
Contributor

jreback commented Sep 2, 2016

this is a special case duplicate of #4160; renaming of a MI is not tested much at all and the implementation needs fixing. PR's are welcome (#13766 is a start of one).

@jreback jreback closed this as completed Sep 2, 2016
@jreback jreback added Bug MultiIndex Duplicate Report Duplicate issue or pull request labels Sep 2, 2016
@jreback jreback added this to the No action milestone Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request MultiIndex
Projects
None yet
Development

No branches or pull requests

2 participants