Skip to main content
`Ctrl`+`K`

# pandas.MultiIndex.truncate

MultiIndex.truncate(before=None, after=None)

  Slice index between two labels / tuples, return new MultiIndex.

  Parameters:
    before label or tuple, can be partial. Default None

      None defaults to start.

    after label or tuple, can be partial. Default None

      None defaults to end.

  Returns:
    MultiIndex

      The truncated MultiIndex.

  See also

  `DataFrame.truncate`

    Truncate a DataFrame before and after some index values.

  `Series.truncate`

    Truncate a Series before and after some index values.

  Examples

      >>> mi = pd.MultiIndex.from_arrays([["a", "b", "c"], ["x", "y", "z"]])
      >>> mi
      MultiIndex([('a', 'x'), ('b', 'y'), ('c', 'z')],
                 )
      >>> mi.truncate(before="a", after="b")
      MultiIndex([('a', 'x'), ('b', 'y')],
                 )