Transformation Fill#
- group Filling
Functions
-
void fill_in_place(mutable_column_view &destination, size_type begin, size_type end, scalar const &value, rmm::cuda_stream_view stream = cudf::get_default_stream())#
Fills a range of elements in-place in a column with a scalar value.
Fills N elements of
destinationstarting atbeginwithvalue, where N = (end-begin).Overwrites the range of elements in
destinationindicated by the indices [begin,end) withvalue. Use the out-of-place fill function returning std::unique_ptr<column> for use cases requiring memory reallocation.- Throws:
cudf::logic_error – if memory reallocation is required (e.g. for variable width types).
cudf::logic_error – for invalid range (if
begin< 0,begin>end, orend>destination.size()).cudf::logic_error – if
destinationandvaluehave different types.cudf::logic_error – if
valueis invalid butdestinationis not nullable.
- Parameters:
destination – The preallocated column to fill into
begin – The starting index of the fill range (inclusive)
end – The index of the last element in the fill range (exclusive)
value – The scalar value to fill
stream – CUDA stream used for device memory operations and kernel launches
-
std::unique_ptr<column> fill(column_view const &input, size_type begin, size_type end, scalar const &value, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Fills a range of elements in a column out-of-place with a scalar value.
Creates a new column as-if an in-place fill was performed into
input; i.e. it is as if a copy ofinputwas created first and then the elements indicated by the indices [begin,end) were overwritten byvalue.- Throws:
cudf::logic_error – for invalid range (if
begin< 0,begin>end, orend>destination.size()).cudf::logic_error – if
destinationandvaluehave different types.
- Parameters:
input – The input column used to create a new column. The new column is created by replacing the values of
inputin the specified range withvalue.begin – The starting index of the fill range (inclusive)
end – The index of the last element in the fill range (exclusive)
value – The scalar value to fill
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
The result output column
-
std::unique_ptr<table> repeat(table_view const &input_table, column_view const &count, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Repeat rows of a Table.
Creates a new table by repeating the rows of
input_table. The number of repetitions of each element is defined by the value at the corresponding index ofcountExample:in = [4,5,6] count = [1,2,3] return = [4,5,5,6,6,6]
countshould not have null values; should not contain negative values; and the sum of count elements should not overflow the size_type’s limit. The behavior of this function is undefined ifcounthas negative values or the sum overflows.- Throws:
cudf::logic_error – if the data type of
countis not size_type.cudf::logic_error – if
input_tableandcounthave different number of rows.cudf::logic_error – if
counthas null values.
- Parameters:
input_table – Input table
count – Non-nullable column of an integral type
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned table’s device memory
- Returns:
The result table containing the repetitions
-
std::unique_ptr<table> repeat(table_view const &input_table, size_type count, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Repeat rows of a Table.
Creates a new table by repeating
counttimes the rows ofinput_table. Example:in = [4,5,6] count = 2 return = [4,4,5,5,6,6]
- Throws:
cudf::logic_error – if
countis negative.std::overflow_error – if
input_table.num_rows()*countoverflows size_type.
- Parameters:
input_table – Input table
count – Number of repetitions
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned table’s device memory
- Returns:
The result table containing the repetitions
-
std::unique_ptr<column> sequence(size_type size, scalar const &init, scalar const &step, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Fills a column with a sequence of value specified by an initial value and a step.
Creates a new column and fills with
sizevalues starting atinitand incrementing bystep, generating the sequence [ init, init+step, init+2*step, … init + (size - 1)*step]size = 3 init = 0 step = 2 return = [0, 2, 4]
- Throws:
std::invalid_argument – if
initandstepare not the same type.std::invalid_argument – if scalar types are not numeric or invalid
std::invalid_argument – if
sizeis < 0.
- Parameters:
size – Size of the output column
init – First value in the sequence
step – Increment value
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
The result column containing the generated sequence
-
std::unique_ptr<column> sequence(size_type size, scalar const &init, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Fills a column with a sequence of value specified by an initial value and a step of 1.
Creates a new column and fills with
sizevalues starting atinitand incrementing by 1, generating the sequence [ init, init+1, init+2, … init + (size - 1)]size = 3 init = 0 return = [0, 1, 2]
- Throws:
std::invalid_argument – if
initis not numeric or invalidstd::invalid_argument – if
sizeis < 0
- Parameters:
size – Size of the output column
init – First value in the sequence
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
The result column containing the generated sequence
-
std::unique_ptr<cudf::column> calendrical_month_sequence(size_type size, scalar const &init, size_type months, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Generate a sequence of timestamps beginning at
initand incrementing bymonthsfor each successive element, i.e.,output[i] = init + i * monthsforiin[0, size).If a given date is invalid, the date is scaled back to the last available day of that month.
Example:
size = 3 init = 2020-01-31 08:00:00 months = 1 return = [2020-01-31 08:00:00, 2020-02-29 08:00:00, 2020-03-31 08:00:00]
- Throws:
cudf::logic_error – if input datatype is not a TIMESTAMP
- Parameters:
size – Number of timestamps to generate
init – The initial timestamp
months – Months to increment
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
Timestamps column with sequences of months
-
void fill_in_place(mutable_column_view &destination, size_type begin, size_type end, scalar const &value, rmm::cuda_stream_view stream = cudf::get_default_stream())#