Index.
nlevels
Number of levels in Index & MultiIndex.
Examples
>>> psdf = ps.DataFrame({"a": [1, 2, 3]}, index=pd.Index(['a', 'b', 'c'], name="idx")) >>> psdf.index.nlevels 1
>>> psdf = ps.DataFrame({'a': [1, 2, 3]}, index=[list('abc'), list('def')]) >>> psdf.index.nlevels 2