@@ -318,13 +318,13 @@ As usual, **both sides** of the slicers are included as this is label indexing.
318318
319319 .. code-block :: python
320320
321- df.loc[(slice (' A1' ,' A3' ),... .. ), :]
321+ df.loc[(slice (' A1' , ' A3' ), ... ), :] # noqa: E999
322322
323323 You should **not ** do this:
324324
325325 .. code-block :: python
326326
327- df.loc[(slice (' A1' ,' A3' ),... ..)]
327+ df.loc[(slice (' A1' , ' A3' ), ... )] # noqa: E999
328328
329329 .. ipython :: python
330330
@@ -740,15 +740,13 @@ values **not** in the categories, similarly to how you can reindex **any** panda
740740
741741 .. code-block :: python
742742
743- In [9 ]: df3 = pd.DataFrame({' A' : np.arange(6 ),
744- ' B' : pd.Series(list (' aabbca' )).astype(' category' )})
743+ >> > df3 = pd.DataFrame({' A' : np.arange(6 ),
744+ ... ' B' : pd.Series(list (' aabbca' )).astype(' category' )})
745+ >> > df3 = df3.set_index(' B' )
746+ >> > df3.index
747+ CategoricalIndex([u ' a' , u ' a' , u ' b' , u ' b' , u ' c' , u ' a' ], categories = [u ' a' , u ' b' , u ' c' ], ordered = False , name = u ' B' , dtype = ' category' )
745748
746- In [11 ]: df3 = df3.set_index(' B' )
747-
748- In [11 ]: df3.index
749- Out[11 ]: CategoricalIndex([u ' a' , u ' a' , u ' b' , u ' b' , u ' c' , u ' a' ], categories = [u ' a' , u ' b' , u ' c' ], ordered = False , name = u ' B' , dtype = ' category' )
750-
751- In [12 ]: pd.concat([df2, df3]
749+ >> > pd.concat([df2, df3])
752750 TypeError : categories must match existing categories when appending
753751
754752 .. _indexing.rangeindex :
@@ -1033,11 +1031,11 @@ On the other hand, if the index is not monotonic, then both slice bounds must be
10331031 .. code-block :: python
10341032
10351033 # 0 is not in the index
1036- In [ 9 ]: df.loc[0 :4 , :]
1034+ >> > df.loc[0 :4 , :]
10371035 KeyError : 0
10381036
10391037 # 3 is not a unique label
1040- In [ 11 ]: df.loc[2 :3 , :]
1038+ >> > df.loc[2 :3 , :]
10411039 KeyError : ' Cannot get right slice bound for non-unique label: 3'
10421040
10431041 ``Index.is_monotonic_increasing `` and ``Index.is_monotonic_decreasing `` only check that
0 commit comments