Trait polars::chunked_array::object::ChunkApply [−][src]
pub trait ChunkApply<'a, A, B> { fn apply_cast_numeric<F, S>(&'a self, f: F) -> ChunkedArray<S>
where
F: Fn(A) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType; fn branch_apply_cast_numeric_no_null<F, S>(
&'a self,
f: F
) -> ChunkedArray<S>
where
F: Fn(Option<A>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType; fn apply<F>(&'a self, f: F) -> Self
where
F: Fn(A) -> B + Copy; fn apply_on_opt<F>(&'a self, f: F) -> Self
where
F: Fn(Option<A>) -> Option<B> + Copy; fn apply_with_idx<F>(&'a self, f: F) -> Self
where
F: Fn((usize, A)) -> B + Copy; fn apply_with_idx_on_opt<F>(&'a self, f: F) -> Self
where
F: Fn((usize, Option<A>)) -> Option<B> + Copy; }
Expand description
Fastest way to do elementwise operations on a ChunkedArray
Required methods
fn apply_cast_numeric<F, S>(&'a self, f: F) -> ChunkedArray<S> where
F: Fn(A) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]
fn apply_cast_numeric<F, S>(&'a self, f: F) -> ChunkedArray<S> where
F: Fn(A) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]Apply a closure elementwise and cast to a Numeric ChunkedArray. This is fastest when the null check branching is more expensive than the closure application.
Null values remain null.
fn branch_apply_cast_numeric_no_null<F, S>(&'a self, f: F) -> ChunkedArray<S> where
F: Fn(Option<A>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]
fn branch_apply_cast_numeric_no_null<F, S>(&'a self, f: F) -> ChunkedArray<S> where
F: Fn(Option<A>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]Apply a closure on optional values and cast to Numeric ChunkedArray without null values.
Apply a closure elementwise. This is fastest when the null check branching is more expensive than the closure application. Often it is.
Null values remain null.
Example
use polars_core::prelude::*; fn double(ca: &UInt32Chunked) -> UInt32Chunked { ca.apply(|v| v * 2) }
Apply a closure elementwise including null values.
Apply a closure elementwise. The closure gets the index of the element as first argument.
Implementors
pub fn apply_cast_numeric<F, S>(&'a self, f: F) -> ChunkedArray<S> where
F: Fn(&'a str) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn branch_apply_cast_numeric_no_null<F, S>(
&'a self,
f: F
) -> ChunkedArray<S> where
F: Fn(Option<&'a str>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn apply<F>(&'a self, f: F) -> ChunkedArray<Utf8Type> where
F: Fn(&'a str) -> Cow<'a, str> + Copy,
[src]pub fn apply_on_opt<F>(&'a self, f: F) -> ChunkedArray<Utf8Type> where
F: Fn(Option<&'a str>) -> Option<Cow<'a, str>> + Copy,
[src]pub fn apply_cast_numeric<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(bool) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn branch_apply_cast_numeric_no_null<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Option<bool>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn apply_on_opt<F>(&'a self, f: F) -> ChunkedArray<BooleanType> where
F: Fn(Option<bool>) -> Option<bool> + Copy,
[src]pub fn apply_with_idx<F>(&'a self, f: F) -> ChunkedArray<BooleanType> where
F: Fn((usize, bool)) -> bool + Copy,
[src]pub fn apply_with_idx_on_opt<F>(&'a self, f: F) -> ChunkedArray<BooleanType> where
F: Fn((usize, Option<bool>)) -> Option<bool> + Copy,
[src]Apply a closure F
elementwise.
Apply a closure elementwise. The closure gets the index of the element as first argument.
Apply a closure elementwise. The closure gets the index of the element as first argument.
pub fn apply_cast_numeric<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Series) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn branch_apply_cast_numeric_no_null<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Option<Series>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn apply_on_opt<F>(&'a self, f: F) -> ChunkedArray<ListType> where
F: Fn(Option<Series>) -> Option<Series> + Copy,
[src]impl<'a, T> ChunkApply<'a, <T as ArrowPrimitiveType>::Native, <T as ArrowPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
[src]
impl<'a, T> ChunkApply<'a, <T as ArrowPrimitiveType>::Native, <T as ArrowPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
[src]pub fn apply_cast_numeric<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(<T as ArrowPrimitiveType>::Native) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn branch_apply_cast_numeric_no_null<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Option<<T as ArrowPrimitiveType>::Native>) -> <S as ArrowPrimitiveType>::Native + Copy,
S: PolarsNumericType,
[src]pub fn apply<F>(&'a self, f: F) -> ChunkedArray<T> where
F: Fn(<T as ArrowPrimitiveType>::Native) -> <T as ArrowPrimitiveType>::Native + Copy,
[src]pub fn apply_on_opt<F>(&'a self, f: F) -> ChunkedArray<T> where
F: Fn(Option<<T as ArrowPrimitiveType>::Native>) -> Option<<T as ArrowPrimitiveType>::Native> + Copy,
[src]pub fn apply_with_idx<F>(&'a self, f: F) -> ChunkedArray<T> where
F: Fn((usize, <T as ArrowPrimitiveType>::Native)) -> <T as ArrowPrimitiveType>::Native + Copy,
[src]pub fn apply_with_idx_on_opt<F>(&'a self, f: F) -> ChunkedArray<T> where
F: Fn((usize, Option<<T as ArrowPrimitiveType>::Native>)) -> Option<<T as ArrowPrimitiveType>::Native> + Copy,
[src]