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/pandas.errors.UnsortedIndexError.html below:

pandas.errors.UnsortedIndexError — pandas 2.3.1 documentation

pandas.errors.UnsortedIndexError#
exception pandas.errors.UnsortedIndexError[source]#

Error raised when slicing a MultiIndex which has not been lexsorted.

Subclass of KeyError.

Examples

>>> df = pd.DataFrame({"cat": [0, 0, 1, 1],
...                    "color": ["white", "white", "brown", "black"],
...                    "lives": [4, 4, 3, 7]},
...                   )
>>> df = df.set_index(["cat", "color"])
>>> df
            lives
cat  color
0    white    4
     white    4
1    brown    3
     black    7
>>> df.loc[(0, "black"):(1, "white")]
Traceback (most recent call last):
UnsortedIndexError: 'Key length (2) was greater
than MultiIndex lexsort depth (1)'

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