pandas.api.types.union_categoricals()

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

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.20.2/generated/pandas.api.types.union_categoricals.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部