A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/../api/pandas.MultiIndex.droplevel.html below:

pandas.MultiIndex.droplevel — pandas 2.3.1 documentation

pandas.MultiIndex.droplevel#
MultiIndex.droplevel(level=0)[source]#

Return index with requested level(s) removed.

If resulting index has only 1 level left, the result will be of Index type, not MultiIndex. The original index is not modified inplace.

Parameters:
levelint, str, or list-like, default 0

If a string is given, must be the name of a level If list-like, elements must be names or indexes of levels.

Returns:
Index or MultiIndex

Examples

>>> mi = pd.MultiIndex.from_arrays(
... [[1, 2], [3, 4], [5, 6]], names=['x', 'y', 'z'])
>>> mi
MultiIndex([(1, 3, 5),
            (2, 4, 6)],
           names=['x', 'y', 'z'])
>>> mi.droplevel()
MultiIndex([(3, 5),
            (4, 6)],
           names=['y', 'z'])
>>> mi.droplevel(2)
MultiIndex([(1, 3),
            (2, 4)],
           names=['x', 'y'])
>>> mi.droplevel('z')
MultiIndex([(1, 3),
            (2, 4)],
           names=['x', 'y'])
>>> mi.droplevel(['x', 'y'])
Index([5, 6], dtype='int64', name='z')

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4