Files | Functions

Files

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

Functions

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.

Examples
-------------------------------------------------
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]
Note
if the input is nullable, the output will be nullable.
if the fill value is null, the output will be nullable.
Parameters
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
Exceptions
cudf::logic_errorif input dtype is not fixed-with.
cudf::logic_errorif fill_value dtype does not match input dtype.