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


Python cudf.DataFrame.label_encoding用法及代碼示例

用法:

DataFrame.label_encoding(column, prefix, cats, prefix_sep='_', dtype=None, na_sentinel=- 1)

使用標簽編碼對列中的標簽進行編碼。

參數

columnstr

數據的二進製編碼的源列。

prefixstr

新的列名前綴。

cats整數序列

作為整數的類別序列。

prefix_sepstr

前綴和類別之間的分隔符。

dtype :

輸出的 dtype;見係列。label_encoding

na_sentinel數字

表示缺失類別的值。

返回

一個新的 DataFrame,為編碼值附加了一個新列。

例子

>>> import cudf
>>> df = cudf.DataFrame({'a':[1, 2, 3], 'b':[10, 10, 20]})
>>> df
   a   b
0  1  10
1  2  10
2  3  20
>>> df.label_encoding(column="b", prefix="b_col", cats=[10, 20])
   a   b  b_col_labels
0  1  10             0
1  2  10             0
2  3  20             1

相關用法


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