polars_arrow::compute::arity

Function unary

Source
pub fn unary<I, F, O>(
    array: &PrimitiveArray<I>,
    op: F,
    dtype: ArrowDataType,
) -> PrimitiveArray<O>
where I: NativeType, O: NativeType, F: Fn(I) -> O,
Expand description

Applies an unary and infallible function to a PrimitiveArray.

This is the /// fastest way to perform an operation on a PrimitiveArray when the benefits of a vectorized operation outweighs the cost of branching nulls and non-nulls.

ยงImplementation

This will apply the function for all values, including those on null slots. This implies that the operation must be infallible for any value of the corresponding type or this function may panic.