Skip to content

Commit 9d4a905

Browse files
committed
review doc fixes
1 parent 2c7f02e commit 9d4a905

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/source/categorical.rst

+6
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ are consistent among all columns.
185185
df_cat['A']
186186
df_cat['B']
187187
188+
.. note::
189+
190+
To perform table-wise conversion, where all labels in the entire ``DataFrame`` are used as
191+
categories for each column, the ``categories`` parameter can be determined programatically by
192+
``categories = pd.unique(df.values.ravel())``.
193+
188194
If you already have `codes` and `categories`, you can use the
189195
:func:`~pandas.Categorical.from_codes` constructor to save the factorize step
190196
during normal constructor mode:

doc/source/whatsnew/v0.23.0.txt

+6-7
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,14 @@ The :func:`DataFrame.assign` now accepts dependent keyword arguments for python
271271

272272
.. _whatsnew_0230.enhancements.astype_category:
273273

274-
``DataFrame.astype`` performs columnwise conversion to ``Categorical``
275-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274+
``DataFrame.astype`` performs column-wise conversion to ``Categorical``
275+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
276276

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

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

282283
.. ipython:: python
283284

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

301-
See the :ref:`categorical.objectcreation` section of the documentation for more details and examples.
302-
303302
.. _whatsnew_0230.enhancements.other:
304303

305304
Other Enhancements

0 commit comments

Comments
 (0)