@@ -24,25 +24,61 @@ API changes
2424- Indexing in ``MultiIndex `` beyond lex-sort depth is now supported, though
2525 a lexically sorted index will have a better performance. (:issue: `2646 `)
2626
27- .. ipython :: python
28- :okexcept:
29- :okwarning:
27+ .. code-block :: ipython
28+
29+ In [1]: df = pd.DataFrame({'jim':[0, 0, 1, 1],
30+ ...: 'joe':['x', 'x', 'z', 'y'],
31+ ...: 'jolie':np.random.rand(4)}).set_index(['jim', 'joe'])
32+ ...:
3033
31- df = pd.DataFrame({' jim' :[0 , 0 , 1 , 1 ],
32- ' joe' :[' x' , ' x' , ' z' , ' y' ],
33- ' jolie' :np.random.rand(4 )}).set_index([' jim' , ' joe' ])
34- df
35- df.index.lexsort_depth
34+ In [2]: df
35+ Out[2]:
36+ jolie
37+ jim joe
38+ 0 x 0.126970
39+ x 0.966718
40+ 1 z 0.260476
41+ y 0.897237
42+
43+ [4 rows x 1 columns]
44+
45+ In [3]: df.index.lexsort_depth
46+ Out[3]: 1
3647
3748 # in prior versions this would raise a KeyError
3849 # will now show a PerformanceWarning
39- df.loc[(1 , ' z' )]
50+ In [4]: df.loc[(1, 'z')]
51+ Out[4]:
52+ jolie
53+ jim joe
54+ 1 z 0.260476
55+
56+ [1 rows x 1 columns]
4057
4158 # lexically sorting
42- df2 = df.sort_index()
43- df2
44- df2.index.lexsort_depth
45- df2.loc[(1 ,' z' )]
59+ In [5]: df2 = df.sort_index()
60+
61+ In [6]: df2
62+ Out[6]:
63+ jolie
64+ jim joe
65+ 0 x 0.126970
66+ x 0.966718
67+ 1 y 0.897237
68+ z 0.260476
69+
70+ [4 rows x 1 columns]
71+
72+ In [7]: df2.index.lexsort_depth
73+ Out[7]: 2
74+
75+ In [8]: df2.loc[(1,'z')]
76+ Out[8]:
77+ jolie
78+ jim joe
79+ 1 z 0.260476
80+
81+ [1 rows x 1 columns]
4682
4783 - Bug in unique of Series with ``category `` dtype, which returned all categories regardless
4884 whether they were "used" or not (see :issue: `8559 ` for the discussion).
0 commit comments