字典编码#
- group 编码
函数
-
std::unique_ptr<column> encode(column_view const &column, data_type indices_type = data_type{type_id::INT32}, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
通过对现有列进行字典编码来构造一个字典列。
输出列是 DICTIONARY 类型,其键列包含按严格全序排列的非空唯一值。也就是说,对于所有
i in [0,n-1)
(其中n
是键的数量),keys[i]
的排序都在keys[i+1]
之前。输出列包含一个子索引列,该列是整数类型,并且大小与输入列相同。
空值掩码和空值计数从输入列复制到输出列。
c = [429, 111, 213, 111, 213, 429, 213] d = encode(c) d now has keys [111, 213, 429] and indices [2, 0, 1, 0, 1, 2, 1]
- 抛出:
cudf::logic_error – 如果索引类型不是有符号整数类型
cudf::logic_error – 如果要编码的列已经是 DICTIONARY 类型
- 参数:
column – 要进行字典编码的列
indices_type – 用于索引的整数类型
stream – 用于设备内存操作和内核启动的 CUDA 流
mr – 用于分配返回列的设备内存的设备内存资源
- 返回:
返回一个字典列
-
std::unique_ptr<column> decode(dictionary_column_view const &dictionary_column, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
通过使用给定 dictionary_column 中的索引,从该列的键中收集数据来创建新列。
d1 = {["a", "c", "d"], [2, 0, 1, 0]} s = decode(d1) s is now ["d", "a", "c", "a"]
- 参数:
dictionary_column – 现有字典列
stream – 用于设备内存操作和内核启动的 CUDA 流
mr – 用于分配返回列的设备内存的设备内存资源
- 返回:
新列的类型与 dictionary_column 的键类型匹配
-
std::unique_ptr<column> encode(column_view const &column, data_type indices_type = data_type{type_id::INT32}, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#