Transformation Unaryops#
- group transformation_unaryops
Enums
-
enum class rounding_method : int32_t#
Different rounding methods for
cudf::round
Info on HALF_EVEN rounding: https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even Info on HALF_UP rounding: https://en.wikipedia.org/wiki/Rounding#Rounding_half_away_from_zero Note: HALF_UP means up in MAGNITUDE: Away from zero! Because of how Java and python define it
Values:
-
enumerator HALF_UP#
-
enumerator HALF_EVEN#
-
enumerator HALF_UP#
-
enum class unary_operator : int32_t#
Types of unary operations that can be performed on data.
Values:
-
enumerator SIN#
Trigonometric sine.
-
enumerator COS#
Trigonometric cosine.
-
enumerator TAN#
Trigonometric tangent.
-
enumerator ARCSIN#
Trigonometric sine inverse.
-
enumerator ARCCOS#
Trigonometric cosine inverse.
-
enumerator ARCTAN#
Trigonometric tangent inverse.
-
enumerator SINH#
Hyperbolic sine.
-
enumerator COSH#
Hyperbolic cosine.
-
enumerator TANH#
Hyperbolic tangent.
-
enumerator ARCSINH#
Hyperbolic sine inverse.
-
enumerator ARCCOSH#
Hyperbolic cosine inverse.
-
enumerator ARCTANH#
Hyperbolic tangent inverse.
-
enumerator EXP#
Exponential (base e, Euler number)
-
enumerator LOG#
Natural Logarithm (base e)
-
enumerator SQRT#
Square-root (x^0.5)
-
enumerator CBRT#
Cube-root (x^(1.0/3))
-
enumerator CEIL#
Smallest integer value not less than arg.
-
enumerator FLOOR#
largest integer value not greater than arg
-
enumerator ABS#
Absolute value.
-
enumerator RINT#
Rounds the floating-point argument arg to an integer value.
-
enumerator BIT_INVERT#
Bitwise Not (~)
-
enumerator NOT#
Logical Not (!)
-
enumerator SIN#
Functions
-
std::unique_ptr<column> round(column_view const &input, int32_t decimal_places = 0, rounding_method method = rounding_method::HALF_UP, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Rounds all the values in a column to the specified number of decimal places.
cudf::round
currently supports HALF_UP and HALF_EVEN rounding for integer, floating point anddecimal32
anddecimal64
numbers. Fordecimal32
anddecimal64
numbers, negatednumeric::scale
is equivalent todecimal_places
.Example:
using namespace cudf; column_view a; // contains { 1.729, 17.29, 172.9, 1729 }; auto result1 = round(a); // { 2, 17, 173, 1729 } auto result2 = round(a, 1); // { 1.7, 17.3, 172.9, 1729 } auto result3 = round(a, -1); // { 0, 20, 170, 1730 } column_view b; // contains { 1.5, 2.5, 1.35, 1.45, 15, 25 }; auto result4 = round(b, 0, rounding_method::HALF_EVEN); // { 2, 2, 1, 1, 15, 25}; auto result5 = round(b, 1, rounding_method::HALF_EVEN); // { 1.5, 2.5, 1.4, 1.4, 15, 25}; auto result6 = round(b, -1, rounding_method::HALF_EVEN); // { 0, 0, 0, 0, 20, 20};
- Parameters:
input – Column of values to be rounded
decimal_places – Number of decimal places to round to (default 0). If negative, this specifies the number of positions to the left of the decimal point.
method – Rounding method
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:
Column with each of the values rounded
-
template<typename Fixed, typename Floating>
Fixed convert_floating_to_fixed(Floating floating, numeric::scale_type scale)# Convert a floating-point value to fixed point.
Note
This conversion was moved from fixed-point member functions to free functions. This is so that the complex conversion code is not included into many parts of the code base that don’t need it, and so that it’s more obvious to pinpoint where these conversions are occurring.
- Template Parameters:
Fixed – The fixed-point type to convert to
Floating – The floating-point type to convert from
- Parameters:
floating – The floating-point value to convert
scale – The desired scale of the fixed-point value
- Returns:
The converted fixed-point value
-
template<typename Floating, typename Fixed>
Floating convert_fixed_to_floating(Fixed fixed)# Convert a fixed-point value to floating point.
Note
This conversion was moved from fixed-point member functions to free functions. This is so that the complex conversion code is not included into many parts of the code base that don’t need it, and so that it’s more obvious to pinpoint where these conversions are occurring.
- Template Parameters:
Floating – The floating-point type to convert to
Fixed – The fixed-point type to convert from
- Parameters:
fixed – The fixed-point value to convert
- Returns:
The converted floating-point value
-
template<typename Floating, typename Input>
Floating convert_to_floating(Input input)# Convert a value to floating point.
- Template Parameters:
Floating – The floating-point type to convert to
Input – The input type to convert from
- Parameters:
input – The input value to convert
- Returns:
The converted floating-point value
-
std::unique_ptr<cudf::column> unary_operation(cudf::column_view const &input, cudf::unary_operator op, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Performs unary op on all values in column.
Note: For
decimal32
anddecimal64
, onlyABS
,CEIL
andFLOOR
are supported.- Parameters:
input – A
column_view
as inputop – operation to perform
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:
Column of same size as
input
containing result of the operation
-
std::unique_ptr<cudf::column> is_null(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Creates a column of
type_id::BOOL8
elements where for every element ininput
true
indicates the value is null andfalse
indicates the value is valid.- Parameters:
input – A
column_view
as inputstream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
A non-nullable column of
type_id::BOOL8
elements withtrue
representingnull
values.
-
std::unique_ptr<cudf::column> is_valid(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Creates a column of
type_id::BOOL8
elements where for every element ininput
true
indicates the value is valid andfalse
indicates the value is null.- Parameters:
input – A
column_view
as inputstream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Returns:
A non-nullable column of
type_id::BOOL8
elements withfalse
representingnull
values.
-
std::unique_ptr<column> cast(column_view const &input, data_type out_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Casts data from dtype specified in input to dtype specified in output.
Supports only fixed-width types.
- Parameters:
input – Input column
out_type – Desired datatype of output column
stream – CUDA stream used for device memory operations and kernel launches
mr – Device memory resource used to allocate the returned column’s device memory
- Throws:
cudf::logic_error – if
out_type
is not a fixed-width type- Returns:
Column of same size as
input
containing result of the cast operation
-
bool is_supported_cast(data_type from, data_type to) noexcept#
Check if a cast between two datatypes is supported.
- Parameters:
from – source type
to – target type
- Returns:
true if the cast is supported.
-
std::unique_ptr<column> is_nan(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Creates a column of
type_id::BOOL8
elements indicating the presence ofNaN
values in a column of floating point values. The output element at rowi
istrue
if the element ininput
at row i isNAN
, elsefalse
- Throws:
cudf::logic_error – if
input
is a non-floating point type- Parameters:
input – A column of floating-point elements
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:
A non-nullable column of
type_id::BOOL8
elements withtrue
representingNAN
values
-
std::unique_ptr<column> is_not_nan(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Creates a column of
type_id::BOOL8
elements indicating the absence ofNaN
values in a column of floating point values. The output element at rowi
isfalse
if the element ininput
at row i isNAN
, elsetrue
- Throws:
cudf::logic_error – if
input
is a non-floating point type- Parameters:
input – A column of floating-point elements
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:
A non-nullable column of
type_id::BOOL8
elements withfalse
representingNAN
values
-
enum class rounding_method : int32_t#