pandas.MultiIndex.levshape#

property MultiIndex.levshape[source]#

A tuple representing the length of each level in the MultiIndex.

In a MultiIndex, each level can contain multiple unique values. The levshape property provides a quick way to assess the size of each level by returning a tuple where each entry represents the number of unique values in that specific level. This is particularly useful in scenarios where you need to understand the structure and distribution of your index levels, such as when working with multidimensional data.

See also

MultiIndex.shape

Return a tuple of the shape of the MultiIndex.

MultiIndex.levels

Returns the levels of the MultiIndex.

Examples

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