Skip to main content
`Ctrl`+`K`

# pandas.Index.join

final Index.join(other, *, how='left', level=None, return_indexers=False, sort=False)

  Compute join_index and indexers to conform data structures to the new index.

  This method computes the result of a join between two Index objects using the specified join type, and optionally returns integer indexers that map each original index to the new joined index.

  Parameters:
    other Index

      The other index on which join is performed.

    how{‘left’, ‘right’, ‘inner’, ‘outer’}
    level int or level name, default None

      It is either the integer position or the name of the level.

    return_indexers bool, default False

      Whether to return the indexers or not for both the index objects.

    sort bool, default False

      Sort the join keys lexicographically in the result Index. If False, the order of the join keys depends on the join type (how keyword).

  Returns:
    join_index, (left_indexer, right_indexer)

      The new index.

  See also

  `DataFrame.join`

    Join columns with other DataFrame either on index or on a key.

  `DataFrame.merge`

    Merge DataFrame or named Series objects with a database-style join.

  Examples

      >>> idx1 = pd.Index([1, 2, 3])
      >>> idx2 = pd.Index([4, 5, 6])
      >>> idx1.join(idx2, how="outer")
      Index([1, 2, 3, 4, 5, 6], dtype='int64')
      >>> idx1.join(other=idx2, how="outer", return_indexers=True)
      (Index([1, 2, 3, 4, 5, 6], dtype='int64'),
      array([ 0,  1,  2, -1, -1, -1]), array([-1, -1, -1,  0,  1,  2]))