cudf.MultiIndex.droplevel#

MultiIndex.droplevel(level=-1)[source]#

Removes the specified levels from the MultiIndex.

Parameters:
levellevel name or index, list-like

Integer, name or list of such, specifying one or more levels to drop from the MultiIndex

Returns:
A MultiIndex or Index object, depending on the number of remaining
levels.

Examples

>>> import cudf
>>> idx = cudf.MultiIndex.from_frame(
...     cudf.DataFrame(
...         {
...             "first": ["a", "a", "a", "b", "b", "b"],
...             "second": [1, 1, 2, 2, 3, 3],
...             "third": [0, 1, 2, 0, 1, 2],
...         }
...     )
... )

Dropping level by index:

>>> idx.droplevel(0)
MultiIndex([(1, 0),
            (1, 1),
            (2, 2),
            (2, 0),
            (3, 1),
            (3, 2)],
           names=['second', 'third'])

Dropping level by name:

>>> idx.droplevel("first")
MultiIndex([(1, 0),
            (1, 1),
            (2, 2),
            (2, 0),
            (3, 1),
            (3, 2)],
           names=['second', 'third'])

Dropping multiple levels:

>>> idx.droplevel(["first", "second"])
Index([0, 1, 2, 0, 1, 2], dtype='int64', name='third')