copying#
- pylibcudf.copying.MaskAllocationPolicy#
See also
cudf::mask_allocation_policy
.Enum members
NEVER
RETAIN
ALWAYS
- pylibcudf.copying.OutOfBoundsPolicy#
See also
cudf::out_of_bounds_policy
.Enum members
NULLIFY
DONT_CHECK
- pylibcudf.copying.allocate_like(Column input_column, mask_allocation_policy policy, size=None) Column #
Allocate a column with the same type as input_column.
For details, see
allocate_like()
.- Parameters:
- input_columnColumn
The column to use as a template for the output.
- policymask_allocation_policy
Controls whether the output column has a valid mask.
- sizeint, optional
The number of elements to allocate in the output column. If not specified, the size of the input column is used.
- Returns:
- pylibcudf.Column
A column with the same type and size as input.
- pylibcudf.copying.boolean_mask_scatter(signatures, args, kwargs, defaults, _fused_sigindex={})#
Scatter rows from input into target according to boolean_mask.
If source is a table, it specifies rows to scatter. If source is a list, each scalar is scattered into the corresponding column in the
target_table
.For details on the implementation, see
boolean_mask_scatter()
.- Parameters:
- inputUnion[Table, List[Scalar]]
The table object from which to pull data.
- targetTable
The table object into which to scatter data.
- boolean_maskColumn
A mapping from rows in input to rows in target.
- Returns:
- Table
The result of the scatter
- Raises:
- ValueError
If input.num_columns() != target.num_columns(), boolean_mask.size() != target.num_rows(), or if input is a Table and the number of true in boolean_mask > input.num_rows().
- TypeError
If any input type does not match the corresponding target column’s type, or if boolean_mask.type() is not bool.
- pylibcudf.copying.copy_if_else(signatures, args, kwargs, defaults, _fused_sigindex={})#
Copy elements from lhs or rhs into a new column according to boolean_mask.
For details on the implementation, see
copy_if_else()
.- Parameters:
- lhsUnion[Column, Scalar]
The column or scalar to copy from if the corresponding element in boolean_mask is True.
- rhsUnion[Column, Scalar]
The column or scalar to copy from if the corresponding element in boolean_mask is False.
- boolean_maskColumn
The boolean mask to use to select elements from lhs and rhs.
- Returns:
- pylibcudf.Column
The result of copying elements from lhs and rhs according to boolean_mask.
- Raises:
- TypeError
If lhs and rhs are not of the same type or if the boolean mask is not of type bool.
- ValueError
If boolean mask is not of the same length as lhs and rhs (whichever are columns), or if lhs and rhs are not of the same length (if both are columns).
- pylibcudf.copying.copy_range(Column input_column, Column target_column, size_type input_begin, size_type input_end, size_type target_begin) Column #
Copy a range of elements from input_column to target_column.
For details on the implementation, see
copy_range()
.- Parameters:
- input_columnColumn
The column from which to copy elements.
- target_columnColumn
The column into which to copy elements.
- input_beginint
The index of the first element in input_column to copy.
- input_endint
The index of the last element in input_column to copy.
- target_beginint
The index of the first element in target_column to overwrite.
- Returns:
- pylibcudf.Column
A copy of target_column with the specified range overwritten.
- Raises:
- IndexError
If the indices accessed by the ranges implied by input_begin, input_end, and target_begin are out of bounds.
- TypeError
If target and source have different types.
- pylibcudf.copying.copy_range_in_place(Column input_column, Column target_column, size_type input_begin, size_type input_end, size_type target_begin) Column #
Copy a range of elements from input_column to target_column.
The target_column is overwritten in place.
For details on the implementation, see
copy_range_in_place()
.- Parameters:
- input_columnColumn
The column from which to copy elements.
- target_columnColumn
The column into which to copy elements.
- input_beginint
The index of the first element in input_column to copy.
- input_endint
The index of the last element in input_column to copy.
- target_beginint
The index of the first element in target_column to overwrite.
- Raises:
- TypeError
If the operation is attempted on non-fixed width types since those would require memory reallocations, or if the input and target columns have different types.
- IndexError
If the indices accessed by the ranges implied by input_begin, input_end, and target_begin are out of bounds.
- ValueError
If source has null values and target is not nullable.
- pylibcudf.copying.empty_like(signatures, args, kwargs, defaults, _fused_sigindex={})#
Create an empty column or table with the same type as
input
.For details, see
empty_like()
.- Parameters:
- inputUnion[Column, Table]
The column or table to use as a template for the output.
- Returns:
- Union[Column, Table]
An empty column or table with the same type(s) as
input
.
- pylibcudf.copying.gather(Table source_table, Column gather_map, out_of_bounds_policy bounds_policy) Table #
Select rows from source_table according to the provided gather_map.
For details, see
gather()
.- Parameters:
- source_tableTable
The table object from which to pull data.
- gather_mapColumn
The list of row indices to pull out of the source table.
- bounds_policyout_of_bounds_policy
Controls whether out of bounds indices are checked and nullified in the output or if indices are assumed to be in bounds.
- Returns:
- pylibcudf.Table
The result of the gather
- Raises:
- ValueError
If the gather_map contains nulls.
- pylibcudf.copying.get_element(Column input_column, size_type index) Scalar #
Get the element at index from input_column.
For details on the implementation, see
get_element()
.- Parameters:
- input_columnColumn
The column from which to get the element.
- indexint
The index of the element to get.
- Returns:
- pylibcudf.Scalar
The element at index from input_column.
- Raises:
- IndexError
If index is out of bounds.
- pylibcudf.copying.scatter(signatures, args, kwargs, defaults, _fused_sigindex={})#
Scatter from source into target_table according to scatter_map.
If source is a table, it specifies rows to scatter. If source is a list, each scalar is scattered into the corresponding column in the
target_table
.For details, see
scatter()
.- Parameters:
- sourceUnion[Table, List[Scalar]]
The table object or list of scalars from which to pull data.
- scatter_mapColumn
A mapping from rows in source to rows in target_table.
- target_tableTable
The table object into which to scatter data.
- Returns:
- Table
The result of the scatter
- Raises:
- ValueError
- If any of the following occur:
scatter_map contains null values.
source is a Table and the number of columns in source does not match the number of columns in target.
source is a Table and the number of rows in source does not match the number of elements in scatter_map.
source is a List[Scalar] and the number of scalars does not match the number of columns in target.
- TypeError
If data types of the source and target columns do not match.
- pylibcudf.copying.shift(Column input, size_type offset, Scalar fill_value) Column #
Shift the elements of input by offset.
For details on the implementation, see
shift()
.- Parameters:
- inputColumn
The column to shift.
- offsetint
The number of elements to shift by.
- fill_valuesScalar
The value to use for elements that are shifted in from outside the bounds of the input column.
- Returns:
- pylibcudf.Column
A copy of input shifted by offset.
- Raises:
- TypeError
If the fill_value is not of the same type as input, or if the input type is not of fixed width or string type.
- pylibcudf.copying.slice(signatures, args, kwargs, defaults, _fused_sigindex={})#
Slice input according to indices.
For details on the implementation, see
slice()
.- Parameters:
- input_columnUnion[Column, Table]
The column or table to slice.
- indicesList[int]
The indices to select from input.
- Returns:
- List[Union[Column, Table]]
The result of slicing
input
.
- Raises:
- ValueError
If indices size is not even or the values in any pair of lower/upper bounds are strictly decreasing.
- IndexError
When any of the indices don’t belong to the range
[0, input_column.size())
.
- pylibcudf.copying.split(signatures, args, kwargs, defaults, _fused_sigindex={})#
Split input into multiple.
For details on the implementation, see
split()
.- Parameters:
- inputUnion[Column, Table]
The column to split.
- splitsList[int]
The indices at which to split the column.
- Returns:
- List[Union[Column, Table]]
The result of splitting input.