Skip to main content
`Ctrl`+`K`

# pandas.MultiIndex.codes

property MultiIndex.codes

  Codes of the MultiIndex.

  Codes are the position of the index value in the list of level values for each level.

  Returns:
    tuple of numpy.ndarray

      The codes of the MultiIndex. Each array in the tuple corresponds to a level in the MultiIndex.

  See also

  `MultiIndex.set_codes`

    Set new codes on MultiIndex.

  Examples

      >>> arrays = [[1, 1, 2, 2], ["red", "blue", "red", "blue"]]
      >>> mi = pd.MultiIndex.from_arrays(arrays, names=("number", "color"))
      >>> mi.codes
      FrozenList([[0, 0, 1, 1], [1, 0, 1, 0]])