(left, right, lefti, righti, string_cols=None)
return res
Join (horizontally) two arrays, taking pairs of rows given in indices
Join (horizontally) two arrays, taking pairs of rows given in indices
Join ( horizontally ) two arrays taking pairs of rows given in indices
def _join_array_by_indices(left, right, lefti, righti, string_cols=None):
        """Join (horizontally) two arrays, taking pairs of rows given in indices
        """
        def prepare(arr, inds, str_cols):
            try:
                newarr = arr[inds]
            except IndexError:
                newarr = np.full_like(arr, np.nan)
            else:
                empty = np.full(arr.shape[1], np.nan)
                if str_cols:
                    assert arr.dtype == object
                    empty = empty.astype(object)
                    empty[str_cols] = ''
                newarr[inds == -1] = empty
            return newarr

        left_width = left.shape[1]
        str_left = [i for i in string_cols or () if i < left_width]
        str_right = [i - left_width for i in string_cols or () if i >= left_width]
        res = hstack((prepare(left, lefti, str_left),
                      prepare(right, righti, str_right)))
        return res
def _join_array_by_indices ( left , right , lefti , righti , string_cols = None ) : def prepare ( arr , inds , str_cols ) : try : newarr = arr [ inds ] except IndexError : newarr = np . full_like ( arr , np . nan ) else : empty = np . full ( arr . shape [ 1 ] , np . nan ) if str_cols : assert arr . dtype == object empty = empty . astype ( object ) empty [ str_cols ] = '' newarr [ inds == - 1 ] = empty return newarr left_width = left . shape [ 1 ] str_left = [ i for i in string_cols or ( ) if i < left_width ] str_right = [ i - left_width for i in string_cols or ( ) if i >= left_width ] res = hstack ( ( prepare ( left , lefti , str_left ) , prepare ( right , righti , str_right ) ) ) return res