File tree 4 files changed +13
-4
lines changed
4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -528,12 +528,14 @@ return a copy of the data rather than a view:
528
528
jim joe
529
529
1 z 0.64094
530
530
531
+ .. _advanced.unsorted :
532
+
531
533
Furthermore if you try to index something that is not fully lexsorted, this can raise:
532
534
533
535
.. code-block :: ipython
534
536
535
537
In [5]: dfm.loc[(0,'y'):(1, 'z')]
536
- KeyError : 'Key length (2) was greater than MultiIndex lexsort depth (1)'
538
+ UnsortedIndexError : 'Key length (2) was greater than MultiIndex lexsort depth (1)'
537
539
538
540
The ``is_lexsorted() `` method on an ``Index `` show if the index is sorted, and the ``lexsort_depth `` property returns the sort depth:
539
541
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ What's New
18
18
19
19
These are new features and improvements of note in each release.
20
20
21
+ .. include :: whatsnew/v0.20.0.txt
22
+
21
23
.. include :: whatsnew/v0.19.2.txt
22
24
23
25
.. include :: whatsnew/v0.19.1.txt
Original file line number Diff line number Diff line change @@ -41,10 +41,12 @@ Other enhancements
41
41
42
42
- ``pd.read_excel`` now preserves sheet order when using ``sheetname=None`` (:issue:`9930`)
43
43
44
- - New ``UnsortedIndexError`` (subclass of ``KeyError``) thrown when indexing into an
45
- unsorted MultiIndex (:issue:'11897`)
44
+ - New ``UnsortedIndexError`` (subclass of ``KeyError``) thrown when indexing/slicing into an
45
+ unsorted MultiIndex (:issue:`11897`). This allows differentiation between errors due to lack
46
+ of sorting or an incorrect key. See :ref:`here <advanced.unsorted>`
46
47
47
- - Change message when indexing via a boolean ``Series`` that has an incompatible index (:issue:`14491`)
48
+ - Change error message text corresponding to error raised when indexing via a
49
+ boolean ``Series`` that has an incompatible index (:issue:`14491`)
48
50
49
51
50
52
.. _whatsnew_0200.api_breaking:
Original file line number Diff line number Diff line change @@ -98,6 +98,9 @@ class UnsupportedFunctionCall(ValueError):
98
98
99
99
100
100
class UnsortedIndexError (KeyError ):
101
+ """ This error is raised when attempting to get a slice of a MultiIndex
102
+ and the index has not been lexsorted.
103
+ """
101
104
pass
102
105
103
106
You can’t perform that action at this time.
0 commit comments