

def _join_multi(self, other, how, return_indexers=True):
    from .multi import MultiIndex
    self_is_mi = isinstance(self, MultiIndex)
    other_is_mi = isinstance(other, MultiIndex)
    self_names = [n for n in self.names if (n is not None)]
    other_names = [n for n in other.names if (n is not None)]
    overlap = list((set(self_names) & set(other_names)))
    if (not len(overlap)):
        raise ValueError('cannot join with no level specified and no overlapping names')
    if (len(overlap) > 1):
        raise NotImplementedError('merging with more than one level overlap on a multi-index is not implemented')
    jl = overlap[0]
    if (not (self_is_mi and other_is_mi)):
        flip_order = False
        if self_is_mi:
            (self, other) = (other, self)
            flip_order = True
            how = {
                'right': 'left',
                'left': 'right',
            }.get(how, how)
        level = other.names.index(jl)
        result = self._join_level(other, level, how=how, return_indexers=return_indexers)
        if flip_order:
            if isinstance(result, tuple):
                return (result[0], result[2], result[1])
        return result
    raise NotImplementedError('merging with both multi-indexes is not implemented')

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py Index._join_multi/original