文件 | |
文件 | range_window_bounds.hpp |
文件 | rolling.hpp |
类 | |
结构体 | cudf::range_window_bounds |
窗口边界大小的抽象,用于 grouped_range_rolling_window() 。 更多... | |
结构体 | cudf::bounded_closed |
用于有限闭区间滚动窗口的强类型包装。 更多... | |
结构体 | cudf::bounded_open |
用于有限开区间滚动窗口的强类型包装。 更多... | |
结构体 | cudf::unbounded |
用于无界滚动窗口的强类型包装。 更多... | |
结构体 | cudf::current_row |
用于 当前行 滚动窗口的强类型包装。 更多... | |
结构体 | cudf::window_bounds |
窗口边界大小的抽象。 更多... | |
类型定义 | |
使用 | cudf::range_window_type = std::variant< unbounded, current_row, bounded_closed, bounded_open > |
基于范围的滚动窗口端点的类型。 | |
std::unique_ptr<column> cudf::grouped_range_rolling_window | ( | table_view const & | group_keys, |
column_view const & | orderby_column, | ||
cudf::order const & | order, | ||
column_view const & | input, | ||
range_window_bounds const & | preceding, | ||
range_window_bounds const & | following, | ||
size_type | min_periods, | ||
rolling_aggregation const & | aggr, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用分组感知、基于值范围的滚动窗口函数。
此函数对指定 input
列中每个元素周围的窗口内的行进行聚合。窗口根据有序 orderby
列的值以及表示 orderby 列值包含范围的 preceding
和 following
标量值确定。
input
列中的元素被分组为不同的组(例如 groupby 的结果),由 group_keys
下相应列的值确定。窗口聚合不能跨越组边界。orderby
列排序后,索引为 i
的行的聚合窗口确定如下:a) 如果 orderby
是升序,索引 i
行的聚合窗口包含所有索引为 j
的 input
行,满足orderby
是降序,索引 i
行的聚合窗口包含所有索引为 j
的 input
行,满足注意:此方法要求行按组键和 orderby 列值预排序。
窗口间隔指定为适用于 orderby 列的标量值。目前,仅支持以下 orderby
列类型和范围类型的组合
orderby
列是 TIMESTAMP,则 preceding
/following
窗口以相同分辨率的 DURATION
标量指定。例如,对于 TIMESTAMP_SECONDS
类型的 orderby
列,间隔只能是 DURATION_SECONDS
。不能使用更高分辨率(例如 DURATION_NANOSECONDS
)或更低分辨率(例如 DURATION_DAYS
)的持续时间。orderby
列是整数类型(例如 INT32
),则 preceding
/following
应为完全相同的类型(INT32
)。group_range_rolling_window()
函数允许计算总超车次数注意:每个窗口中参与的行数可能因组内索引、时间戳和 min_periods
而异。例如
每个聚合操作不能跨越组边界。
返回列的类型取决于输入列类型 T
和聚合
INT32
列T
列INT64
。LIST<T>
类型的列。LEAD/LAG/ROW_NUMBER 对于范围查询未定义。
[in] | group_keys | (预排序的)分组列 |
[in] | orderby_column | (预排序的)排序依据列,用于范围比较 |
[in] | order | 排序依据列的排序顺序(升序/降序) |
[in] | input | 输入列(待聚合) |
[in] | preceding | 后向间隔值 |
[in] | following | 前向间隔值 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | aggr | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
std::unique_ptr<column> cudf::grouped_rolling_window | ( | table_view const & | group_keys, |
column_view const & | input, | ||
column_view const & | default_outputs, | ||
size_type | preceding_window, | ||
size_type | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | aggr, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用分组感知、固定大小的滚动窗口函数。
与 rolling_window()
类似,此函数对指定 input
列中每个元素周围的窗口内的值进行聚合。它与 rolling_window()
的不同之处在于 input
列中的元素被分组为不同的组(例如 groupby 的结果)。窗口聚合不能跨越组边界。对于 input
的行 i
,组由 group_keys
下相应(即第 i 个)列的值确定。
注意:此方法要求行按 group_key
值预排序。
grouped_rolling_window()
方法实现了窗口查询,例如按以下方式对数据集分组op == COUNT
返回的列始终为 INT32
类型。所有其他运算符返回与输入类型相同的列。因此建议在进行滚动 MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。
注意:preceding_window
和 following_window
可能包含负值。这会产生可能不包含当前行的窗口。例如,考虑定义为 (preceding=3, following=-1) 的窗口。这会产生一个从当前行之前 2 行(即 3-1)开始的窗口,以及当前行之前 1 行的窗口。对于上面的示例,行 #3 的窗口是
[ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <–window--> ^ | 当前行
类似地,preceding
可能包含负值,表示窗口从当前行之后的位置开始。这与 following
的语义略有不同,因为 preceding
包含当前行。因此
[in] | group_keys | (预排序的)分组列 |
[in] | input | 输入列(待聚合) |
[in] | preceding_window | 后向(正值)或前向(负值)的静态滚动窗口大小 |
[in] | following_window | 前向(正值)或后向(负值)的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | aggr | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
default_outputs | 用于返回每行默认值而不是空值的列。用于 LEAD()/LAG(),如果行偏移量超出列或组的边界。 |
std::unique_ptr<column> cudf::grouped_rolling_window | ( | table_view const & | group_keys, |
column_view const & | input, | ||
column_view const & | default_outputs, | ||
window_bounds | preceding_window, | ||
window_bounds | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | aggr, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用分组感知、固定大小的滚动窗口函数。
与 rolling_window()
类似,此函数对指定 input
列中每个元素周围的窗口内的值进行聚合。它与 rolling_window()
的不同之处在于 input
列中的元素被分组为不同的组(例如 groupby 的结果)。窗口聚合不能跨越组边界。对于 input
的行 i
,组由 group_keys
下相应(即第 i 个)列的值确定。
注意:此方法要求行按 group_key
值预排序。
grouped_rolling_window()
方法实现了窗口查询,例如按以下方式对数据集分组op == COUNT
返回的列始终为 INT32
类型。所有其他运算符返回与输入类型相同的列。因此建议在进行滚动 MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。
注意:preceding_window
和 following_window
可能包含负值。这会产生可能不包含当前行的窗口。例如,考虑定义为 (preceding=3, following=-1) 的窗口。这会产生一个从当前行之前 2 行(即 3-1)开始的窗口,以及当前行之前 1 行的窗口。对于上面的示例,行 #3 的窗口是
[ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <–window--> ^ | 当前行
类似地,preceding
可能包含负值,表示窗口从当前行之后的位置开始。这与 following
的语义略有不同,因为 preceding
包含当前行。因此
[in] | group_keys | (预排序的)分组列 |
[in] | input | 输入列(待聚合) |
[in] | preceding_window | 后向(正值)或前向(负值)的静态滚动窗口大小 |
[in] | following_window | 前向(正值)或后向(负值)的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | aggr | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
default_outputs | 用于返回每行默认值而不是空值的列。用于 LEAD()/LAG(),如果行偏移量超出列或组的边界。 |
std::unique_ptr<column> cudf::grouped_rolling_window | ( | table_view const & | group_keys, |
column_view const & | input, | ||
size_type | preceding_window, | ||
size_type | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | aggr, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用分组感知、固定大小的滚动窗口函数。
与 rolling_window()
类似,此函数对指定 input
列中每个元素周围的窗口内的值进行聚合。它与 rolling_window()
的不同之处在于 input
列中的元素被分组为不同的组(例如 groupby 的结果)。窗口聚合不能跨越组边界。对于 input
的行 i
,组由 group_keys
下相应(即第 i 个)列的值确定。
注意:此方法要求行按 group_key
值预排序。
grouped_rolling_window()
方法实现了窗口查询,例如按以下方式对数据集分组op == COUNT
返回的列始终为 INT32
类型。所有其他运算符返回与输入类型相同的列。因此建议在进行滚动 MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。
注意:preceding_window
和 following_window
可能包含负值。这会产生可能不包含当前行的窗口。例如,考虑定义为 (preceding=3, following=-1) 的窗口。这会产生一个从当前行之前 2 行(即 3-1)开始的窗口,以及当前行之前 1 行的窗口。对于上面的示例,行 #3 的窗口是
[ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <–window--> ^ | 当前行
类似地,preceding
可能包含负值,表示窗口从当前行之后的位置开始。这与 following
的语义略有不同,因为 preceding
包含当前行。因此
[in] | group_keys | (预排序的)分组列 |
[in] | input | 输入列(待聚合) |
[in] | preceding_window | 后向(正值)或前向(负值)的静态滚动窗口大小 |
[in] | following_window | 前向(正值)或后向(负值)的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | aggr | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
std::unique_ptr<column> cudf::grouped_rolling_window | ( | table_view const & | group_keys, |
column_view const & | input, | ||
window_bounds | preceding_window, | ||
window_bounds | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | aggr, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用分组感知、固定大小的滚动窗口函数。
与 rolling_window()
类似,此函数对指定 input
列中每个元素周围的窗口内的值进行聚合。它与 rolling_window()
的不同之处在于 input
列中的元素被分组为不同的组(例如 groupby 的结果)。窗口聚合不能跨越组边界。对于 input
的行 i
,组由 group_keys
下相应(即第 i 个)列的值确定。
注意:此方法要求行按 group_key
值预排序。
grouped_rolling_window()
方法实现了窗口查询,例如按以下方式对数据集分组op == COUNT
返回的列始终为 INT32
类型。所有其他运算符返回与输入类型相同的列。因此建议在进行滚动 MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。
注意:preceding_window
和 following_window
可能包含负值。这会产生可能不包含当前行的窗口。例如,考虑定义为 (preceding=3, following=-1) 的窗口。这会产生一个从当前行之前 2 行(即 3-1)开始的窗口,以及当前行之前 1 行的窗口。对于上面的示例,行 #3 的窗口是
[ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <–window--> ^ | 当前行
类似地,preceding
可能包含负值,表示窗口从当前行之后的位置开始。这与 following
的语义略有不同,因为 preceding
包含当前行。因此
[in] | group_keys | (预排序的)分组列 |
[in] | input | 输入列(待聚合) |
[in] | preceding_window | 后向(正值)或前向(负值)的静态滚动窗口大小 |
[in] | following_window | 前向(正值)或后向(负值)的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | aggr | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
std::pair<std::unique_ptr<column>, std::unique_ptr<column> > cudf::make_range_windows | ( | table_view const & | group_keys, |
column_view const & | orderby, | ||
order | order, | ||
null_order | null_order, | ||
range_window_type | preceding, | ||
range_window_type | following, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
根据窗口范围规范构造前向和后向列。
group_keys | 可能为空的已排序键表,用于定义组。 |
orderby | 定义窗口范围的列。必须已排序。如果 group_keys 非空,则必须按组排序。 |
order | orderby 列的排序顺序。 |
null_order | 已排序 orderby 列中的空值排序顺序。如果 group_keys 非空,则按组应用。 |
preceding | 前向窗口的类型。 |
following | 后向窗口的类型。 |
stream | 用于设备内存操作和内核启动的 CUDA 流 |
mr | 用于分配返回列设备内存的设备内存资源 |
rolling_window
。std::unique_ptr<column> cudf::rolling_window | ( | column_view const & | input, |
column_view const & | default_outputs, | ||
size_type | preceding_window, | ||
size_type | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | agg, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用固定大小的滚动窗口函数。
此函数对 input 列中每个元素 i 周围的窗口内的值进行聚合,如果观测数量不足,则使元素 i 的位掩码无效。窗口大小是静态的(每个元素都相同)。这与 Pandas DataFrame.rolling 的 API 匹配,但有一些显著差异
preceding_window + following_window
。元素 i
使用元素 [i-preceding_window+1, i+following_window]
进行窗口计算。关于返回列类型的说明
INT32
类型。FLOAT64
类型。MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。[in] | input | 输入列 |
[in] | preceding_window | 后向的静态滚动窗口大小 |
[in] | following_window | 前向的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | agg | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
default_outputs | 用于返回每行默认值而不是空值的列。用于 LEAD()/LAG(),如果行偏移量超出列的边界。 |
std::unique_ptr<column> cudf::rolling_window | ( | column_view const & | input, |
column_view const & | preceding_window, | ||
column_view const & | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | agg, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用变长滚动窗口函数。
此函数对 input 列中每个元素 i 周围的窗口内的值进行聚合,如果观测数量不足,则使元素 i 的位掩码无效。窗口大小是动态的(每个元素都不同)。这与 Pandas DataFrame.rolling 的 API 匹配,但有一些显著差异
preceding_window + following_window
。元素 i
使用元素 [i-preceding_window+1, i+following_window]
进行窗口计算。COUNT 聚合返回的列始终为 INT32 类型。所有其他运算符返回与输入类型相同的列。因此建议在进行滚动 MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。
preceding_window
和 following_window
中的所有条目必须生成对 input
有效的窗口范围。也就是说,对于所有 i
,要求由区间 [i - preceding_window[i] + 1, ..., i + following_window[i] + 1)
定义的行集是 [0, input.size())
的子集。cudf::logic_error | 如果窗口列类型不是 INT32 |
[in] | input | 输入列 |
[in] | preceding_window | 前向的 INT32 窗口大小非空列。preceding_window[i] 指定元素 i 的前向窗口大小。 |
[in] | following_window | 后向的 INT32 窗口大小非空列。following_window[i] 指定元素 i 的后向窗口大小。 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | agg | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |
std::unique_ptr<column> cudf::rolling_window | ( | column_view const & | input, |
size_type | preceding_window, | ||
size_type | following_window, | ||
size_type | min_periods, | ||
rolling_aggregation const & | agg, | ||
rmm::cuda_stream_view | stream = cudf::get_default_stream() , |
||
rmm::device_async_resource_ref | mr = cudf::get_current_device_resource_ref() |
||
) |
对列中的值应用固定大小的滚动窗口函数。
此函数对 input 列中每个元素 i 周围的窗口内的值进行聚合,如果观测数量不足,则使元素 i 的位掩码无效。窗口大小是静态的(每个元素都相同)。这与 Pandas DataFrame.rolling 的 API 匹配,但有一些显著差异
preceding_window + following_window
。元素 i
使用元素 [i-preceding_window+1, i+following_window]
进行窗口计算。关于返回列类型的说明
INT32
类型。FLOAT64
类型。MEAN
之前,将整数列类型(特别是低精度整数)转换为 FLOAT32
或 FLOAT64
。[in] | input | 输入列 |
[in] | preceding_window | 后向的静态滚动窗口大小 |
[in] | following_window | 前向的静态滚动窗口大小 |
[in] | min_periods | 窗口中需要包含的最小观测数量才能有值,否则元素 i 为空。 |
[in] | agg | 滚动窗口聚合类型(总和、最大值、最小值等) |
[in] | stream | 用于设备内存操作和内核启动的 CUDA 流 |
[in] | mr | 用于分配返回列设备内存的设备内存资源 |