Skip to content

Commit 66cdd66

Browse files
committed
DOC: fixup categorical news
1 parent e487a30 commit 66cdd66

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

doc/source/10min.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,14 @@ Categoricals
640640
------------
641641

642642
Since version 0.15, pandas can include categorical data in a ``DataFrame``. For full docs, see the
643-
:ref:`Categorical introduction <categorical>` and the :ref:`API documentation <api.categorical>` .
643+
:ref:`categorical introduction <categorical>` and the :ref:`API documentation <api.categorical>` .
644644

645645
.. ipython:: python
646646
647647
df = pd.DataFrame({"id":[1,2,3,4,5,6], "raw_grade":['a', 'b', 'b', 'a', 'a', 'e']})
648648
649649
# convert the raw grades to a categorical
650-
df["grade"] = pd.Categorical(df["raw_grade"])
651-
652-
# Alternative: df["grade"] = df["raw_grade"].astype("category")
650+
df["grade"] = df["raw_grade"].astype("category")
653651
df["grade"]
654652
655653
# Rename the categories inplace
@@ -658,7 +656,9 @@ Since version 0.15, pandas can include categorical data in a ``DataFrame``. For
658656
# Reorder the categories and simultaneously add the missing categories
659657
df["grade"] = df["grade"].cat.set_categories(["very bad", "bad", "medium", "good", "very good"])
660658
df["grade"]
659+
# Sorting is per order in the categories
661660
df.sort("grade")
661+
# groupby shows also empty categories
662662
df.groupby("grade").size()
663663
664664

doc/source/v0.15.0.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,21 +540,18 @@ Categoricals in Series/DataFrame
540540
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
541541

542542
:class:`~pandas.Categorical` can now be included in `Series` and `DataFrames` and gained new
543-
methods to manipulate. Thanks to Jan Schultz for much of this API/implementation. (:issue:`3943`, :issue:`5313`, :issue:`5314`,
543+
methods to manipulate. Thanks to Jan Schulz for much of this API/implementation. (:issue:`3943`, :issue:`5313`, :issue:`5314`,
544544
:issue:`7444`, :issue:`7839`, :issue:`7848`, :issue:`7864`, :issue:`7914`, :issue:`7768`, :issue:`8006`, :issue:`3678`,
545545
:issue:`8075`, :issue:`8076`, :issue:`8143`).
546546

547-
For full docs, see the :ref:`Categorical introduction <categorical>` and the
547+
For full docs, see the :ref:`categorical introduction <categorical>` and the
548548
:ref:`API documentation <api.categorical>`.
549549

550550
.. ipython:: python
551551

552552
df = pd.DataFrame({"id":[1,2,3,4,5,6], "raw_grade":['a', 'b', 'b', 'a', 'a', 'e']})
553553

554-
# convert the raw grades to a categorical
555-
df["grade"] = pd.Categorical(df["raw_grade"])
556-
557-
# Alternative: df["grade"] = df["raw_grade"].astype("category")
554+
df["grade"] = df["raw_grade"].astype("category")
558555
df["grade"]
559556

560557
# Rename the categories

0 commit comments

Comments
 (0)