Skip to content

Commit

Permalink
DOC: update to reflect changes in Categorical
Browse files Browse the repository at this point in the history
* rename of levels -> categories
* don't use the `Categorical` constructor if thats not needed
* introduce the new methods to manipulate categories
  • Loading branch information
jankatins committed Sep 25, 2014
1 parent 4c45d7f commit 3f282da
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 315 deletions.
8 changes: 4 additions & 4 deletions doc/source/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,11 @@ Since version 0.15, pandas can include categorical data in a ``DataFrame``. For
# Alternative: df["grade"] = df["raw_grade"].astype("category")
df["grade"]
# Rename the levels
df["grade"].cat.levels = ["very good", "good", "very bad"]
# Rename the categories inplace
df["grade"].cat.categories = ["very good", "good", "very bad"]
# Reorder the levels and simultaneously add the missing levels
df["grade"].cat.reorder_levels(["very bad", "bad", "medium", "good", "very good"])
# Reorder the categories and simultaneously add the missing categories
df["grade"] = df["grade"].cat.set_categories(["very bad", "bad", "medium", "good", "very good"])
df["grade"]
df.sort("grade")
df.groupby("grade").size()
Expand Down
Loading

0 comments on commit 3f282da

Please sign in to comment.