Skip to content

Commit 77e7963

Browse files
committed
doc notes
1 parent 7b37c34 commit 77e7963

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

doc/source/categorical.rst

+23
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,29 @@ In this case the categories are not the same and so an error is raised:
648648
649649
The same applies to ``df.append(df_different)``.
650650

651+
.. _categorical.union:
652+
653+
Unioning
654+
~~~~~~~~
655+
656+
If you want to combine categoricals that do not necessarily have
657+
the same categories, the `union_categorical` function will
658+
combine a list-like of categoricals. The new categories
659+
will be the union of the categories being combined.
660+
661+
.. ipython:: python
662+
663+
from pandas.types.concat import union_categoricals
664+
a = pd.Categorical(["b", "c"])
665+
b = pd.Categorical(["a", "b"])
666+
union_categoricals([a, b])
667+
668+
.. note::
669+
670+
`union_categoricals` only works with unordered categoricals
671+
and will raise if any are orderd.
672+
673+
651674
Getting Data In/Out
652675
-------------------
653676

doc/source/whatsnew/v0.18.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Other enhancements
9090

9191
- The ``DataFrame`` constructor will now respect key ordering if a list of ``OrderedDict`` objects are passed in (:issue:`13304`)
9292
- ``pd.read_html()`` has gained support for the ``decimal`` option (:issue:`12907`)
93-
93+
- A ``union_categorical`` function has been added for combining categoricals, see :ref:`Unioning Categoricals<categorical.union>` (:issue:`13361`)
9494
- ``eval``'s upcasting rules for ``float32`` types have been updated to be more consistent with NumPy's rules. New behavior will not upcast to ``float64`` if you multiply a pandas ``float32`` object by a scalar float64. (:issue:`12388`)
9595
- ``Series`` has gained the properties ``.is_monotonic``, ``.is_monotonic_increasing``, ``.is_monotonic_decreasing``, similar to ``Index`` (:issue:`13336`)
9696

0 commit comments

Comments
 (0)