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.levelsGet the levels of the MultiIndex.
MultiIndex.codesGet the codes of the MultiIndex.
MultiIndex.from_arraysConvert arrays to MultiIndex.
MultiIndex.from_tuplesConvert list of tuples to MultiIndex.
Examples
>>> mi = pd.MultiIndex.from_arrays([["a"], ["b"], ["c"]]) >>> mi MultiIndex([('a', 'b', 'c')], ) >>> mi.nlevels 3