pandas.MultiIndex.nlevels#

property MultiIndex.nlevels[source]#

Integer number of levels in this MultiIndex.

This property returns the count of levels (i.e., the depth of the hierarchical index), which corresponds to the number of arrays or columns used to construct the MultiIndex.

See also

MultiIndex.levels

Get the levels of the MultiIndex.

MultiIndex.codes

Get the codes of the MultiIndex.

MultiIndex.from_arrays

Convert arrays to MultiIndex.

MultiIndex.from_tuples

Convert list of tuples to MultiIndex.

Examples

>>> mi = pd.MultiIndex.from_arrays([["a"], ["b"], ["c"]])
>>> mi
MultiIndex([('a', 'b', 'c')],
           )
>>> mi.nlevels
3