Skip to content

Commit 3f282da

Browse files
committed
DOC: update to reflect changes in Categorical
* rename of levels -> categories * don't use the `Categorical` constructor if thats not needed * introduce the new methods to manipulate categories
1 parent 4c45d7f commit 3f282da

File tree

4 files changed

+295
-315
lines changed

4 files changed

+295
-315
lines changed

doc/source/10min.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,11 @@ Since version 0.15, pandas can include categorical data in a ``DataFrame``. For
652652
# Alternative: df["grade"] = df["raw_grade"].astype("category")
653653
df["grade"]
654654
655-
# Rename the levels
656-
df["grade"].cat.levels = ["very good", "good", "very bad"]
655+
# Rename the categories inplace
656+
df["grade"].cat.categories = ["very good", "good", "very bad"]
657657
658-
# Reorder the levels and simultaneously add the missing levels
659-
df["grade"].cat.reorder_levels(["very bad", "bad", "medium", "good", "very good"])
658+
# Reorder the categories and simultaneously add the missing categories
659+
df["grade"] = df["grade"].cat.set_categories(["very bad", "bad", "medium", "good", "very good"])
660660
df["grade"]
661661
df.sort("grade")
662662
df.groupby("grade").size()

0 commit comments

Comments
 (0)