Skip to content

"IndexingError: Unalignable boolean Series key provided" when passing an empty object Series #5877

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
sadruddin opened this issue Jan 8, 2014 · 6 comments · Fixed by #5880
Labels
API Design Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@sadruddin
Copy link

For some reason, with 0.13, an empty object Series is interpreted as a boolean one, when using to fetch elements in another Series:

pandas.Series(['A', 'B'])[pandas.Series([], dtype=object)]

The following works though, so the dtype confusion seems to be confined to empty Series:

pandas.Series(['A', 'B'])[pandas.Series(['C'], dtype=object)]
@jreback
Copy link
Contributor

jreback commented Jan 8, 2014

hmm...

the 2nd acts like a reindex, while the 1st is odd as well

marking as a bug/api issue...

what do you think they should do?

@sadruddin
Copy link
Author

Why do you think that the 2nd is odd? Isn't it what one would expect when passing a Series, i.e. something equivalent to passing an array (using the Series' values)?
I would expect the 1st to return the same thing as what happens when passing a Series of dtype float, i.e. an empty Series. N.B: This used to work in 0.12

@jreback
Copy link
Contributor

jreback commented Jan 8, 2014

@sadruddin see #5880
should close this

The handling of a bool dtyped indexer that is empty would raise in 0.12. I changed it to work in 0.13, but could go either way. thoughts? (its the 3rd one down)

@sadruddin
Copy link
Author

In my opinion, given bool's special case, any non-matching length bool dtyped pandas.Series, including with length 0, should raise an exception. So 0.12 behaviour seems logical to me.

@jreback
Copy link
Contributor

jreback commented Jan 8, 2014

agreed....reverting back to that behavior..

@jreback
Copy link
Contributor

jreback commented Jan 8, 2014

@sadruddin thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Bug Dtype Conversions Unexpected or buggy dtype conversions 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