Files | Functions


file  copying.hpp
 Column APIs for gather, scatter, split, slice, etc.


std::unique_ptr< columncudf::shift (column_view const &input, size_type offset, scalar const &fill_value, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Creates a new column by shifting all values by an offset. More...

Detailed Description

Function Documentation

◆ shift()

std::unique_ptr<column> cudf::shift ( column_view const &  input,
size_type  offset,
scalar const &  fill_value,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 

Creates a new column by shifting all values by an offset.

Elements will be determined by output[idx] = input[idx - offset]. Some elements in the output may be indeterminable from the input. For those elements, the value will be determined by fill_values.

input = [0, 1, 2, 3, 4]
offset = 3
fill_values = @
return = [@, @, @, 0, 1]
input = [5, 4, 3, 2, 1]
offset = -2
fill_values = 7
return = [3, 2, 1, 7, 7]
if the input is nullable, the output will be nullable.
if the fill value is null, the output will be nullable.
inputColumn to be shifted.
offsetThe offset by which to shift the input.
fill_valueFill value for indeterminable outputs.
mrDevice memory resource used to allocate the returned result's device memory
cudf::logic_errorif input dtype is neither fixed-width nor string type
cudf::logic_errorif fill_value dtype does not match input dtype.