Skip to content

Commit 7788f46

Browse files
jankatinsjreback
authored andcommitted
Categorical: minor doc cleanups
1 parent 6fdb400 commit 7788f46

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

doc/source/categorical.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ operations (additions, divisions, ...) are not possible.
4141

4242
All values of the `Categorical` are either in `levels` or `np.nan`. Order is defined by
4343
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
4545
levels array.
4646

4747
`Categoricals` are useful in the following cases:
@@ -376,7 +376,6 @@ Groupby will also show "unused" levels:
376376
377377
cats2 = pd.Categorical(["a","a","b","b"], levels=["a","b","c"])
378378
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
380379
df2.groupby(["cats","B"]).mean()
381380
382381
@@ -694,13 +693,15 @@ See also the API documentation for :func:`pandas.Series.reorder_levels` and
694693
Old style constructor usage
695694
~~~~~~~~~~~~~~~~~~~~~~~~~~~
696695
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
699698
to the levels with `-1` as `NaN`. This usage is now deprecated and not available unless
700699
``compat=True`` is passed to the constructor of `Categorical`.
701700
702701
.. ipython:: python
702+
:okwarning:
703703
704+
# This raises a FutureWarning:
704705
cat = pd.Categorical([1,2], levels=[1,2,3], compat=True)
705706
cat.get_values()
706707
@@ -712,7 +713,7 @@ In the default case (``compat=False``) the first argument is interpreted as valu
712713
cat.get_values()
713714
714715
.. 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`
716717
is raised. Please change your code to use the :func:`~pandas.Categorical.from_codes`
717718
constructor instead of adding ``compat=False``.
718719

0 commit comments

Comments
 (0)