Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.api.types.union_categoricals

pandas.api.types.union_categoricals(to_union, sort_categories=False, ignore_order=False)[source]

Combine list-like of Categorical-like, unioning categories. All categories must have the same dtype.

New in version 0.19.0.

Parameters:

to_union : list-like of Categorical, CategoricalIndex,

or Series with dtype=’category’

sort_categories : boolean, default False

If true, resulting categories will be lexsorted, otherwise they will be ordered as they appear in the data.

ignore_order: boolean, default False

If true, the ordered attribute of the Categoricals will be ignored. Results in an unordered categorical.

New in version 0.20.0.

Returns:

result : Categorical

Raises:

TypeError

  • all inputs do not have the same dtype
  • all inputs do not have the same ordered property
  • all inputs are ordered and their categories are not identical
  • sort_categories=True and Categoricals are ordered

ValueError

Empty list of categoricals passed

Scroll To Top