字典编码#
- group dictionary_encode
函数
-
std::unique_ptr<column> encode(column_view const &column, data_type indices_type = data_type{type_id::UINT32}, 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),keys[i]在keys[i+1]之前有序,其中n是键的数量。输出列有一个子索引列,该列是整数类型,并且与输入列的大小相同。
空掩码和空计数从输入列复制到输出列。
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]
- Throws:
cudf::logic_error – 如果索引类型不是无符号整数类型
cudf::logic_error – 如果要编码的列已经是DICTIONARY类型
- Parameters:
column – 要字典编码的列
indices_type – 用于索引的整数类型
stream – 用于设备内存操作和内核启动的CUDA流
mr – 用于分配返回列的设备内存的设备内存资源
- Returns:
返回一个字典列
-
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"]- Parameters:
dictionary_column – 现有的字典列
stream – 用于设备内存操作和内核启动的CUDA流
mr – 用于分配返回列的设备内存的设备内存资源
- Returns:
新列的类型与字典列的键匹配
-
std::unique_ptr<column> encode(column_view const &column, data_type indices_type = data_type{type_id::UINT32}, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#