@@ -661,18 +661,14 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
661661 Reshaping and Comparision operations on a ``CategoricalIndex `` must have the same categories
662662 or a ``TypeError `` will be raised.
663663
664- .. code-block :: python
665-
666- In [9 ]: df3 = pd.DataFrame({' A' : np.arange(6 ),
667- ' B' : pd.Series(list (' aabbca' )).astype(' category' )})
668-
669- In [11 ]: df3 = df3.set_index(' B' )
670-
671- In [11 ]: df3.index
672- 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' )
664+ .. ipython :: python
665+ :okexcept:
673666
674- In [12 ]: pd.concat([df2, df3]
675- TypeError : categories must match existing categories when appending
667+ df3 = pd.DataFrame({' A' : np.arange(6 ),
668+ ' B' : pd.Series(list (' aabbca' )).astype(' category' )})
669+ df3 = df3.set_index(' B' )
670+ df3.index
671+ pd.concat([df2, df3]
676672
677673.. _indexing.float64index:
678674
@@ -738,20 +734,18 @@ In float indexes, slicing using floats is allowed
738734
739735In non- float indexes, slicing using floats will raise a `` TypeError ``
740736
741- .. code- block:: python
742-
743- In [1 ]: pd.Series(range (5 ))[3.5 ]
744- TypeError : the label [3.5 ] is not a proper indexer for this index type (Int64Index)
737+ .. ipython:: python
738+ :okexcept:
745739
746- In [ 1 ]: pd.Series(range (5 ))[3.5 : 4 .5 ]
747- TypeError : the slice start [3.5 ] is not a proper indexer for this index type (Int64Index)
740+ pd.Series(range (5 ))[3.5 ]
741+ pd.Series( range ( 5 )) [3.5 : 4.5 ]
748742
749743Using a scalar float indexer will be deprecated in a future version, but is allowed for now.
750744
751- .. code- block:: python
745+ .. ipython:: python
746+ :okwarning:
752747
753- In [3 ]: pd.Series(range (5 ))[3.0 ]
754- Out[3 ]: 3
748+ pd.Series(range (5 ))[3.0 ]
755749
756750Here is a typical use- case for using this type of indexing. Imagine that you have a somewhat
757751irregular timedelta- like indexing scheme, but the data is recorded as floats. This could for
0 commit comments