[][src]Struct polars::chunked_array::ChunkedArray

pub struct ChunkedArray<T> { /* fields omitted */ }

Implementations

impl<T> ChunkedArray<T> where
    T: PolarsDataType
[src]

pub fn new_from_chunks(name: &str, chunks: Vec<ArrayRef>) -> Self[src]

Create a new ChunkedArray from existing chunks.

pub fn null_bits(&self) -> Vec<(usize, Option<Buffer>)>[src]

impl<T> ChunkedArray<T> where
    T: PolarsDataType,
    ChunkedArray<T>: ChunkOps
[src]

pub fn chunk_id(&self) -> &Vec<usize>[src]

pub fn chunks(&self) -> &Vec<ArrayRef>[src]

A reference to the chunks

pub fn null_count(&self) -> usize[src]

Count the null values.

pub fn is_null(&self) -> BooleanChunked[src]

Get a mask of the null values.

pub fn u32(self) -> Result<UInt32Chunked>[src]

Downcast

pub fn i32(self) -> Result<Int32Chunked>[src]

Downcast

pub fn i64(self) -> Result<Int64Chunked>[src]

Downcast

pub fn f32(self) -> Result<Float32Chunked>[src]

Downcast

pub fn f64(self) -> Result<Float64Chunked>[src]

Downcast

pub fn bool(self) -> Result<BooleanChunked>[src]

Downcast

pub fn utf8(self) -> Result<Utf8Chunked>[src]

Downcast

pub fn date32(self) -> Result<Date32Chunked>[src]

Downcast

pub fn date64(self) -> Result<Date64Chunked>[src]

Downcast

pub fn time64ns(self) -> Result<Time64NsChunked>[src]

Downcast

pub fn duration_ns(self) -> Result<DurationNsChunked>[src]

Downcast

pub fn limit(&self, num_elements: usize) -> Result<Self>[src]

Take a view of top n elements

pub fn filter(&self, filter: &BooleanChunked) -> Result<Self>[src]

Chunk sizes should match or rhs should have one chunk

pub fn append_array(&mut self, other: ArrayRef) -> Result<()>[src]

Append arrow array in place.

pub fn len(&self) -> usize[src]

Combined length of all the chunks.

pub fn get(&self, index: usize) -> AnyType[src]

Get a single value. Beware this is slow.

pub fn slice(&self, offset: usize, length: usize) -> Result<Self>[src]

Slice the array. The chunks are reallocated the underlying data slices are zero copy.

pub fn head(&self, length: Option<usize>) -> Self[src]

Get the head of the ChunkedArray

pub fn tail(&self, length: Option<usize>) -> Self[src]

Get the tail of the ChunkedArray

pub fn append(&mut self, other: &Self) where
    Self: Sized
[src]

Append in place.

impl ChunkedArray<Utf8Type>[src]

pub fn new_utf8_from_slice<S: AsRef<str>>(name: &str, v: &[S]) -> Self[src]

pub fn new_utf8_from_opt_slice<S: AsRef<str>>(
    name: &str,
    opt_v: &[Option<S>]
) -> Self
[src]

impl<T> ChunkedArray<T> where
    T: PolarsDataType,
    ChunkedArray<T>: ChunkOps
[src]

pub fn name(&self) -> &str[src]

Name of the ChunkedArray.

pub fn ref_field(&self) -> &Field[src]

Get a reference to the field.

pub fn rename(&mut self, name: &str)[src]

Rename this ChunkedArray.

impl<T> ChunkedArray<T> where
    T: ArrowPrimitiveType
[src]

pub fn new_from_slice(name: &str, v: &[T::Native]) -> Self[src]

pub fn new_from_opt_slice(name: &str, opt_v: &[Option<T::Native>]) -> Self[src]

pub fn new_with_null_bitmap(
    name: &str,
    v: &[T::Native],
    buffer: Option<Buffer>,
    null_count: usize
) -> Self
[src]

Nullify values in slice with an existing null bitmap

impl<T> ChunkedArray<T> where
    T: PolarsNumericType
[src]

pub fn cont_slice(&self) -> Result<&[T::Native]>[src]

Contiguous slice

pub fn map<B, F>(&self, f: F) -> Result<Map<Copied<Iter<T::Native>>, F>> where
    F: Fn(T::Native) -> B, 
[src]

If cont_slice is successful a closure is mapped over the elements.

Example

use polars::prelude::*;
fn multiply(ca: &UInt32Chunked) -> Result<Series> {
    let mapped = ca.map(|v| v * 2)?;
    Ok(mapped.collect())
}

pub fn map_null_checks<'a, B, F>(
    &'a self,
    f: F
) -> Map<Box<dyn ExactSizeIterator<Item = Option<T::Native>> + 'a>, F> where
    F: Fn(Option<T::Native>) -> B, 
[src]

If cont_slice fails we can fallback on an iterator with null checks and map a closure over the elements.

Example

use polars::prelude::*;
use itertools::Itertools;
fn multiply(ca: &UInt32Chunked) -> Series {
    let mapped_result = ca.map(|v| v * 2);

    if let Ok(mapped) = mapped_result {
        mapped.collect()
    } else {
        ca
        .map_null_checks(|opt_v| opt_v.map(|v |v * 2)).collect()
    }
}

pub fn fold<F, B>(&self, init: B, f: F) -> Result<B> where
    F: Fn(B, T::Native) -> B, 
[src]

If cont_slice is successful a closure can be applied as aggregation

Example

use polars::prelude::*;
fn compute_sum(ca: &UInt32Chunked) -> Result<u32> {
    ca.fold(0, |acc, value| acc + value)
}

pub fn fold_null_checks<F, B>(&self, init: B, f: F) -> B where
    F: Fn(B, Option<T::Native>) -> B, 
[src]

If cont_slice fails we can fallback on an iterator with null checks and a closure for aggregation

Example

use polars::prelude::*;
fn compute_sum(ca: &UInt32Chunked) -> u32 {
    match ca.fold(0, |acc, value| acc + value) {
        // faster sum without null checks was successful
        Ok(sum) => sum,
        // Null values or multiple chunks in ChunkedArray, we need to do more bounds checking
        Err(_) => ca.fold_null_checks(0, |acc, opt_value| {
            match opt_value {
                Some(v) => acc + v,
                None => acc
            }
        })
    }
}

Trait Implementations

impl<T, '_> Add<&'_ ChunkedArray<T>> for &'_ ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = ChunkedArray<T>

The resulting type after applying the + operator.

impl<T> Add<ChunkedArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = Self

The resulting type after applying the + operator.

impl<T> Agg<<T as ArrowPrimitiveType>::Native> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + PartialOrd
[src]

fn sum(&self) -> Option<T::Native>[src]

Returns None if the array is empty or only contains null values.

fn min(&self) -> Option<T::Native>[src]

Returns the minimum value in the array, according to the natural order. Returns an option because the array is nullable.

fn max(&self) -> Option<T::Native>[src]

Returns the maximum value in the array, according to the natural order. Returns an option because the array is nullable.

impl<'a, T> Apply<'a, <T as ArrowPrimitiveType>::Native, <T as ArrowPrimitiveType>::Native> for ChunkedArray<T> where
    T: PolarsNumericType
[src]

fn apply<F>(&'a self, f: F) -> Self where
    F: Fn(T::Native) -> T::Native
[src]

Chooses the fastest path for closure application. Null values remain null.

Example

use polars::prelude::*;
fn double(ca: &UInt32Chunked) -> UInt32Chunked {
    ca.apply(|v| v * 2)
}

impl AsMut<ChunkedArray<BooleanType>> for Series[src]

impl AsMut<ChunkedArray<Float32Type>> for Series[src]

impl AsMut<ChunkedArray<Float64Type>> for Series[src]

impl AsMut<ChunkedArray<Int32Type>> for Series[src]

impl AsMut<ChunkedArray<Int64Type>> for Series[src]

impl AsMut<ChunkedArray<UInt32Type>> for Series[src]

impl AsMut<ChunkedArray<Utf8Type>> for Series[src]

impl AsRef<ChunkedArray<BooleanType>> for Series[src]

impl AsRef<ChunkedArray<Float32Type>> for Series[src]

impl AsRef<ChunkedArray<Float64Type>> for Series[src]

impl AsRef<ChunkedArray<Int32Type>> for Series[src]

impl AsRef<ChunkedArray<Int64Type>> for Series[src]

impl<T> AsRef<ChunkedArray<T>> for ChunkedArray<T>[src]

impl AsRef<ChunkedArray<UInt32Type>> for Series[src]

impl AsRef<ChunkedArray<Utf8Type>> for Series[src]

impl<T> ChunkCast for ChunkedArray<T> where
    T: PolarsNumericType
[src]

impl<T> ChunkFull<<T as ArrowPrimitiveType>::Native> for ChunkedArray<T> where
    T: ArrowPrimitiveType
[src]

impl<T> ChunkOps for ChunkedArray<T> where
    T: PolarsNumericType
[src]

impl<T> ChunkSort<T> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: PartialOrd
[src]

impl<T> Clone for ChunkedArray<T>[src]

impl<'_> CmpOps<&'_ ChunkedArray<BooleanType>> for BooleanChunked[src]

impl<T, '_> CmpOps<&'_ ChunkedArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType
[src]

impl<'_> CmpOps<&'_ ChunkedArray<Utf8Type>> for Utf8Chunked[src]

impl<T, Rhs> CmpOps<Rhs> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: NumCast,
    Rhs: NumComp + ToPrimitive
[src]

impl<T> Debug for ChunkedArray<T>[src]

impl<T, '_> Div<&'_ ChunkedArray<T>> for &'_ ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero + One
[src]

type Output = ChunkedArray<T>

The resulting type after applying the / operator.

impl<T> Div<ChunkedArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero + One
[src]

type Output = Self

The resulting type after applying the / operator.

impl<T> Downcast<PrimitiveArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType
[src]

impl<'a, T> From<&'a ChunkedArray<T>> for Vec<Option<T::Native>> where
    T: ArrowPrimitiveType,
    &'a ChunkedArray<T>: IntoIterator<Item = Option<T::Native>>,
    ChunkedArray<T>: ChunkOps
[src]

impl<'a> From<&'a ChunkedArray<Utf8Type>> for Vec<String>[src]

impl<T> FromIterator<Option<<T as ArrowPrimitiveType>::Native>> for ChunkedArray<T> where
    T: ArrowPrimitiveType
[src]

impl<T> HashJoin<T> for ChunkedArray<T> where
    T: PolarsNumericType + Sync,
    T::Native: Eq + Hash
[src]

impl<'a, T> IntoIterator for &'a ChunkedArray<T> where
    T: PolarsNumericType
[src]

type Item = Option<T::Native>

The type of the elements being iterated over.

type IntoIter = Box<dyn ExactSizeIterator<Item = Option<T::Native>> + 'a>

Which kind of iterator are we turning this into?

impl<'a, T> IntoTakeRandom<'a> for &'a ChunkedArray<T> where
    T: PolarsNumericType
[src]

type Item = T::Native

impl<T, '_> Mul<&'_ ChunkedArray<T>> for &'_ ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = ChunkedArray<T>

The resulting type after applying the * operator.

impl<T> Mul<ChunkedArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = Self

The resulting type after applying the * operator.

impl<T> Pow for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: ToPrimitive
[src]

impl<T> Reverse<T> for ChunkedArray<T> where
    T: PolarsNumericType,
    ChunkedArray<T>: ChunkOps
[src]

impl<T, '_> Sub<&'_ ChunkedArray<T>> for &'_ ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = ChunkedArray<T>

The resulting type after applying the - operator.

impl<T> Sub<ChunkedArray<T>> for ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Zero
[src]

type Output = Self

The resulting type after applying the - operator.

impl<T> Take for ChunkedArray<T> where
    T: PolarsNumericType
[src]

impl<T> Unique<T> for ChunkedArray<T> where
    T: PolarsIntegerType,
    T::Native: Hash + Eq,
    ChunkedArray<T>: ChunkOps
[src]

impl<T, '_> Unique<T> for &'_ ChunkedArray<T> where
    T: PolarsNumericType,
    T::Native: NumCast + ToPrimitive,
    ChunkedArray<T>: ChunkOps
[src]

impl<T> ValueCounts<T> for ChunkedArray<T> where
    T: PolarsIntegerType,
    T::Native: Hash + Eq,
    ChunkedArray<T>: ChunkOps
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for ChunkedArray<T>

impl<T> Send for ChunkedArray<T> where
    T: Send

impl<T> Sync for ChunkedArray<T> where
    T: Sync

impl<T> Unpin for ChunkedArray<T> where
    T: Unpin

impl<T> !UnwindSafe for ChunkedArray<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,