pandas.MultiIndex.codes — pandas 3.0.0.dev0+2106.gb2b2d04e41 documentation (original) (raw)
property MultiIndex.codes[source]#
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.
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]])