@@ -661,14 +661,18 @@ 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- .. ipython :: python
665- :okexcept:
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' )
666673
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]
674+ In [12 ]: pd.concat([df2, df3]
675+ TypeError : categories must match existing categories when appending
672676
673677.. _indexing.float64index:
674678
@@ -734,18 +738,20 @@ In float indexes, slicing using floats is allowed
734738
735739In non- float indexes, slicing using floats will raise a `` TypeError ``
736740
737- .. ipython:: python
738- :okexcept:
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)
739745
740- pd.Series(range (5 ))[3.5 ]
741- pd.Series( range ( 5 )) [3.5 : 4.5 ]
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)
742748
743749Using a scalar float indexer will be deprecated in a future version, but is allowed for now.
744750
745- .. ipython:: python
746- :okwarning:
751+ .. code- block:: python
747752
748- pd.Series(range (5 ))[3.0 ]
753+ In [3 ]: pd.Series(range (5 ))[3.0 ]
754+ Out[3 ]: 3
749755
750756Here is a typical use- case for using this type of indexing. Imagine that you have a somewhat
751757irregular timedelta- like indexing scheme, but the data is recorded as floats. This could for
0 commit comments