Skip to content

BUG: Boolean indexing on an empty series loses index names #4235

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

Closed
miketkelly opened this issue Jul 14, 2013 · 1 comment · Fixed by #4658
Closed

BUG: Boolean indexing on an empty series loses index names #4235

miketkelly opened this issue Jul 14, 2013 · 1 comment · Fixed by #4658
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@miketkelly
Copy link

import pandas as pd

df = pd.DataFrame({'a': [], 'b': [], 'c': []})
df = df.set_index(['a', 'b'])

print df.c.index.names
print df.c[df.c.isnull()].index.names

Output:

['a', 'b']
[None]

The problem is that the empty boolean mask isn't recognized as a boolean array by infer_dtype in inference.pyx.

I have a fix here: 87b9f21d0f298e35c5ec965b48b53ff17d40ab7e. If you agree with the approach I'll submit the PR.

@jreback
Copy link
Contributor

jreback commented Jul 14, 2013

related to #4226 or #4223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants