當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python cudf.core.column.categorical.CategoricalAccessor.as_unordered用法及代碼示例

用法:

CategoricalAccessor.as_unordered(inplace: bool = False) → Optional[SeriesOrIndex]

將分類設置為無序。

參數

inplace布爾值,默認為 False

是否就地設置有序屬性或返回此分類的副本,其中有序設置為 False。

返回

分類的

無序分類或無(如果就位)。

例子

>>> import cudf
>>> s = cudf.Series([10, 1, 1, 2, 10, 2, 10], dtype="category")
>>> s
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1, 2, 10]
>>> s = s.cat.as_ordered()
>>> s
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1 < 2 < 10]
>>> s.cat.as_unordered()
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1, 2, 10]
>>> s.cat.as_unordered(inplace=True)
>>> s
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1, 2, 10]

相關用法


注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.core.column.categorical.CategoricalAccessor.as_unordered。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。