@@ -41,7 +41,7 @@ operations (additions, divisions, ...) are not possible.
41
41
42
42
All values of the `Categorical ` are either in `levels ` or `np.nan `. Order is defined by
43
43
the order of the `levels `, not lexical order of the values. Internally, the data structure
44
- consists of a levels array and an integer array of level_codes which point to the real value in the
44
+ consists of a levels array and an integer array of ` codes ` which point to the real value in the
45
45
levels array.
46
46
47
47
`Categoricals ` are useful in the following cases:
@@ -376,7 +376,6 @@ Groupby will also show "unused" levels:
376
376
377
377
cats2 = pd.Categorical([" a" ," a" ," b" ," b" ], levels = [" a" ," b" ," c" ])
378
378
df2 = pd.DataFrame({" cats" :cats2," B" :[" c" ," d" ," c" ," d" ], " values" :[1 ,2 ,3 ,4 ]})
379
- # This doesn't work yet with two columns -> see failing unittests
380
379
df2.groupby([" cats" ," B" ]).mean()
381
380
382
381
@@ -694,13 +693,15 @@ See also the API documentation for :func:`pandas.Series.reorder_levels` and
694
693
Old style constructor usage
695
694
~~~~~~~~~~~~~~~~~~~~~~~~~~~
696
695
697
- I earlier versions, a `Categorical` could be constructed by passing in precomputed `level_codes `
698
- (called then `labels` ) instead of values with levels. The `level_codes ` are interpreted as pointers
696
+ I earlier versions, a `Categorical` could be constructed by passing in precomputed `codes `
697
+ (called then `labels` ) instead of values with levels. The `codes ` are interpreted as pointers
699
698
to the levels with `- 1 ` as `NaN` . This usage is now deprecated and not available unless
700
699
`` compat=True `` is passed to the constructor of `Categorical` .
701
700
702
701
.. ipython:: python
702
+ :okwarning:
703
703
704
+ # This raises a FutureWarning:
704
705
cat = pd.Categorical([1 ,2 ], levels = [1 ,2 ,3 ], compat = True )
705
706
cat.get_values()
706
707
@@ -712,7 +713,7 @@ In the default case (``compat=False``) the first argument is interpreted as valu
712
713
cat.get_values()
713
714
714
715
.. warning::
715
- Using Categorical with precomputed level_codes and levels is deprecated and a `FutureWarning `
716
+ Using Categorical with precomputed codes and levels is deprecated and a `FutureWarning `
716
717
is raised. Please change your code to use the :func:`~ pandas.Categorical.from_codes`
717
718
constructor instead of adding `` compat=False `` .
718
719
0 commit comments