Skip to content

Commit

Permalink
review doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jschendel committed Feb 26, 2018
1 parent 4c51064 commit cd134a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions doc/source/categorical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ are consistent among all columns.
df_cat['A']
df_cat['B']
.. note::

To perform table-wise conversion, where all labels in the entire ``DataFrame`` are used as
categories for each column, the ``categories`` parameter can be determined programatically by
``categories = pd.unique(df.values.ravel())``.

If you already have `codes` and `categories`, you can use the
:func:`~pandas.Categorical.from_codes` constructor to save the factorize step
during normal constructor mode:
Expand Down
13 changes: 6 additions & 7 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,14 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python

.. _whatsnew_0230.enhancements.astype_category:

``DataFrame.astype`` performs columnwise conversion to ``Categorical``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``DataFrame.astype`` performs column-wise conversion to ``Categorical``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:meth:`DataFrame.astype` can now perform columnwise conversion to ``Categorical`` by supplying the string ``'category'`` or a :class:`~pandas.api.types.CategoricalDtype`.
Previously, attempting this would raise a ``NotImplementedError``. (:issue:`18099`)
:meth:`DataFrame.astype` can now perform column-wise conversion to ``Categorical`` by supplying the string ``'category'`` or
a :class:`~pandas.api.types.CategoricalDtype`. Previously, attempting this would raise a ``NotImplementedError``. See the
:ref:`categorical.objectcreation` section of the documentation for more details and examples. (:issue:`12860`, :issue:`18099`)

Supplying the string ``'category'`` performs columnwise conversion, with only labels appearing in a given column set as categories:
Supplying the string ``'category'`` performs column-wise conversion, with only labels appearing in a given column set as categories:

.. ipython:: python

Expand All @@ -298,8 +299,6 @@ Supplying a ``CategoricalDtype`` will make the categories in each column consist
df['A'].dtype
df['B'].dtype

See the :ref:`categorical.objectcreation` section of the documentation for more details and examples.

.. _whatsnew_0230.enhancements.other:

Other Enhancements
Expand Down

0 comments on commit cd134a8

Please sign in to comment.