@@ -661,18 +661,14 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
661
661
Reshaping and Comparision operations on a ``CategoricalIndex `` must have the same categories
662
662
or a ``TypeError `` will be raised.
663
663
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:
673
666
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]
676
672
677
673
.. _indexing.float64index:
678
674
@@ -738,20 +734,18 @@ In float indexes, slicing using floats is allowed
738
734
739
735
In non- float indexes, slicing using floats will raise a `` TypeError ``
740
736
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:
745
739
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 ]
748
742
749
743
Using a scalar float indexer will be deprecated in a future version, but is allowed for now.
750
744
751
- .. code- block:: python
745
+ .. ipython:: python
746
+ :okwarning:
752
747
753
- In [3 ]: pd.Series(range (5 ))[3.0 ]
754
- Out[3 ]: 3
748
+ pd.Series(range (5 ))[3.0 ]
755
749
756
750
Here is a typical use- case for using this type of indexing. Imagine that you have a somewhat
757
751
irregular timedelta- like indexing scheme, but the data is recorded as floats. This could for
0 commit comments