'Join (horizontally) two arrays, taking pairs of rows given in indices'

@staticmethod
def _join_array_by_indices(left, right, indices, 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, indices[0], str_left), prepare(right, indices[1], str_right)))
    return res
