Skip to content

BUG: incorrect empty list handling in Cython outer_join_indexer #10618

Closed
@agijsberts

Description

@agijsberts

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions