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

BUG: incorrect empty list handling in Cython outer_join_indexer #10618

Closed
agijsberts opened this issue Jul 18, 2015 · 2 comments
Closed

BUG: incorrect empty list handling in Cython outer_join_indexer #10618

agijsberts opened this issue Jul 18, 2015 · 2 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@agijsberts
Copy link
Contributor

The low level Cython routine for outer_join_indexer uses the wrong size to handle the special case that the right array is empty (see: https://github.com/pydata/pandas/blob/master/pandas/src/generate_code.py#L2134). The fix is simple: if the right array is empty (nright == 0), it should of course loop and copy the left array (for i in range(nleft)).

Due to this bug, the merged index and both indexers are never written when the right array is empty:

In [91]: from pandas.algos import outer_join_indexer_float64

In [92]: outer_join_indexer_float64(array([1.,2.,3.]), array([]))
Out[92]: 
(array([  6.92981993e-310,   2.56210349e-316,   4.27255699e+180]),
 array([140261116804248, 140261116804248, 140260374492336]),
 array([140261116804232, 140261116804232,        50534992]))

Index.union already preempts this special case separately, so this bug will only affect a handful of people that interact directly with the Cython algos. If desired, I could prepare a PR tomorrow, though it might be overkill for such a small change.

@jreback
Copy link
Contributor

jreback commented Jul 18, 2015

the code should do the correct thing even when inputs are empty. so a PR would be gr8!

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Jul 18, 2015
@jreback jreback added this to the 0.17.0 milestone Jul 28, 2015
@jreback
Copy link
Contributor

jreback commented Aug 26, 2015

closed by #10619

@jreback jreback closed this as completed Aug 26, 2015
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

No branches or pull requests

2 participants