Function polars::export::arrow::compute::arithmetics::basic::add_scalar
source · [−]pub fn add_scalar<T>(lhs: &PrimitiveArray<T>, rhs: &T) -> PrimitiveArray<T> where
T: NativeArithmetics + Add<T, Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Adds a scalar T to a primitive array of type T. Panics if the sum of the values overflows.
Examples
use arrow2::compute::arithmetics::basic::add_scalar;
use arrow2::array::PrimitiveArray;
let a = PrimitiveArray::from([None, Some(6), None, Some(6)]);
let result = add_scalar(&a, &1i32);
let expected = PrimitiveArray::from([None, Some(7), None, Some(7)]);
assert_eq!(result, expected)