Transformation Unaryops#

group transformation_unaryops

Enums

enum class rounding_method : int32_t#

Different rounding methods for cudf::round

Info on HALF_UP rounding: https://en.wikipedia.org/wiki/Rounding#Round_half_up Info on HALF_EVEN rounding: https://en.wikipedia.org/wiki/Rounding#Round_half_to_even

Values:

enumerator HALF_UP#
enumerator HALF_EVEN#
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 (!)

Functions

std::unique_ptr<column> round(column_view const &input, int32_t decimal_places = 0, rounding_method method = rounding_method::HALF_UP, rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

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 and decimal32 and decimal64 numbers. For decimal32 and decimal64 numbers, negated numeric::scale is equivalent to decimal_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

  • mr – Device memory resource used to allocate the returned column’s device memory

Returns:

Column with each of the values rounded

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::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Performs unary op on all values in column.

Note: For decimal32 and decimal64, only ABS, CEIL and FLOOR are supported.

Parameters:
  • input – A column_view as input

  • op – 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::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Creates a column of type_id::BOOL8 elements where for every element in input true indicates the value is null and false indicates the value is valid.

Parameters:
  • input – A column_view as input

  • 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 with true representing null values.

std::unique_ptr<cudf::column> is_valid(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Creates a column of type_id::BOOL8 elements where for every element in input true indicates the value is valid and false indicates the value is null.

Parameters:
  • input – A column_view as input

  • 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 with false representing null values.

std::unique_ptr<column> cast(column_view const &input, data_type out_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

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

std::unique_ptr<column> is_nan(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Creates a column of type_id::BOOL8 elements indicating the presence of NaN values in a column of floating point values. The output element at row i is true if the element in input at row i is NAN, else false

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 with true representing NAN values

std::unique_ptr<column> is_not_nan(cudf::column_view const &input, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Creates a column of type_id::BOOL8 elements indicating the absence of NaN values in a column of floating point values. The output element at row i is false if the element in input at row i is NAN, else true

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 with false representing NAN values