Struct polars_core::chunked_array::ChunkedArray [−][src]
pub struct ChunkedArray<T> { /* fields omitted */ }
Expand description
ChunkedArray
Every Series contains a ChunkedArray<T>
. Unlike Series, ChunkedArray’s are typed. This allows
us to apply closures to the data and collect the results to a ChunkedArray
of the same type T
.
Below we use an apply to use the cosine function to the values of a ChunkedArray
.
fn apply_cosine(ca: &Float32Chunked) -> Float32Chunked {
ca.apply(|v| v.cos())
}
If we would like to cast the result we could use a Rust Iterator instead of an apply
method.
Note that Iterators are slightly slower as the null values aren’t ignored implicitly.
fn apply_cosine_and_cast(ca: &Float32Chunked) -> Float64Chunked {
ca.into_iter()
.map(|opt_v| {
opt_v.map(|v| v.cos() as f64)
}).collect()
}
Another option is to first cast and then use an apply.
fn apply_cosine_and_cast(ca: &Float32Chunked) -> Float64Chunked {
ca.cast::<Float64Type>()
.unwrap()
.apply(|v| v.cos())
}
Conversion between Series and ChunkedArray’s
Conversion from a Series
to a ChunkedArray
is effortless.
fn to_chunked_array(series: &Series) -> Result<&Int32Chunked>{
series.i32()
}
fn to_series(ca: Int32Chunked) -> Series {
ca.into_series()
}
Iterators
ChunkedArrays
fully support Rust native Iterator
and DoubleEndedIterator traits, thereby
giving access to all the excellent methods available for Iterators.
fn iter_forward(ca: &Float32Chunked) {
ca.into_iter()
.for_each(|opt_v| println!("{:?}", opt_v))
}
fn iter_backward(ca: &Float32Chunked) {
ca.into_iter()
.rev()
.for_each(|opt_v| println!("{:?}", opt_v))
}
Memory layout
ChunkedArray
’s use Apache Arrow as backend for the memory layout.
Arrows memory is immutable which makes it possible to make multiple zero copy (sub)-views from a single array.
To be able to append data, Polars uses chunks to append new memory locations, hence the ChunkedArray<T>
data structure.
Appends are cheap, because it will not lead to a full reallocation of the whole array (as could be the case with a Rust Vec).
However, multiple chunks in a ChunkArray
will slow down the Iterators, arithmetic and other operations.
When multiplying two ChunkArray'
s with different chunk sizes they cannot utilize SIMD for instance.
However, when chunk size don’t match, Iterators will be used to do the operation (instead of arrows upstream implementation, which may utilize SIMD) and
the result will be a single chunked array.
The key takeaway is that by applying operations on a ChunkArray
of multiple chunks, the results will converge to
a ChunkArray
of a single chunk! It is recommended to leave them as is. If you want to have predictable performance
(no unexpected re-allocation of memory), it is advised to call the rechunk after
multiple append operations.
Implementations
pub fn downcast_iter(
&self
) -> impl Iterator<Item = &PrimitiveArray<T::Native>> + DoubleEndedIterator
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = bool> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter<'a>(
&'a self
) -> impl Iterator<Item = &'a str> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = Series> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = &T> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = u32> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
This is supported on crate feature ndarray
only.
ndarray
only.If data is aligned in a single chunk and has no Null values a zero copy view is returned
as an ndarray
This is supported on crate feature ndarray
only.
ndarray
only.If all nested Series
have the same length, a 2 dimensional ndarray::Array
is returned.
object
only.This is supported on crate feature object
only.
object
only.Get a hold to an object that can be formatted or downcasted via the Any trait.
Safety
No bounds checks
This is supported on crate feature object
only.
object
only.Get a hold to an object that can be formatted or downcasted via the Any trait.
This is supported on crate feature random
only.
random
only.Sample n datapoints from this ChunkedArray.
This is supported on crate feature random
only.
random
only.Sample a fraction between 0.0-1.0 of this ChunkedArray.
This is supported on crate feature random
only.
random
only.Create ChunkedArray
with samples from a Normal distribution.
This is supported on crate feature random
only.
random
only.Create ChunkedArray
with samples from a Standard Normal distribution.
This is supported on crate feature strings
only.
strings
only.Extract json path, first match Refer to https://goessner.net/articles/JsonPath/
This is supported on crate feature strings
only.
strings
only.Get the length of the string values.
This is supported on crate feature strings
only.
strings
only.Check if strings contain a regex pattern
This is supported on crate feature strings
only.
strings
only.Replace the leftmost (sub)string by a regex pattern
This is supported on crate feature strings
only.
strings
only.Replace all (sub)strings by a regex pattern
This is supported on crate feature strings
only.
strings
only.Modify the strings to their lowercase equivalent
This is supported on crate feature strings
only.
strings
only.Modify the strings to their uppercase equivalent
This is supported on crate feature strings
only.
strings
only.Concat with the values from a second Utf8Chunked
This is supported on crate feature strings
only.
strings
only.Slice the string values
Determines a substring starting from start
and with optional length length
of each of the elements in array
.
start
can be negative, in which case the start counts from the end of the string.
This is supported on crate feature temporal
only.
temporal
only.Extract month from underlying NaiveDateTime representation. Returns the year number in the calendar date.
This is supported on crate feature temporal
only.
temporal
only.Extract month from underlying NaiveDateTime representation. Returns the month number starting from 1.
The return value ranges from 1 to 12.
This is supported on crate feature temporal
only.
temporal
only.Extract weekday from underlying NaiveDateTime representation. Returns the weekday number where monday = 0 and sunday = 6
This is supported on crate feature temporal
only.
temporal
only.Returns the ISO week number starting from 1. The return value ranges from 1 to 53. (The last week of year differs by years.)
This is supported on crate feature temporal
only.
temporal
only.Extract day from underlying NaiveDateTime representation. Returns the day of month starting from 1.
The return value ranges from 1 to 31. (The last day of month differs by months.)
This is supported on crate feature temporal
only.
temporal
only.Extract hour from underlying NaiveDateTime representation. Returns the hour number from 0 to 23.
This is supported on crate feature temporal
only.
temporal
only.Extract minute from underlying NaiveDateTime representation. Returns the minute number from 0 to 59.
This is supported on crate feature temporal
only.
temporal
only.Extract second from underlying NaiveDateTime representation. Returns the second number from 0 to 59.
This is supported on crate feature temporal
only.
temporal
only.Extract second from underlying NaiveDateTime representation. Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second.
This is supported on crate feature temporal
only.
temporal
only.Returns the day of year starting from 1.
The return value ranges from 1 to 366. (The last day of year differs by years.)
This is supported on crate feature temporal
only.
temporal
only.Format Date64 with a fmt
rule. See chrono strftime/strptime.
This is supported on crate feature temporal
only.
temporal
only.Extract month from underlying NaiveDate representation. Returns the year number in the calendar date.
This is supported on crate feature temporal
only.
temporal
only.Extract month from underlying NaiveDateTime representation. Returns the month number starting from 1.
The return value ranges from 1 to 12.
This is supported on crate feature temporal
only.
temporal
only.Extract weekday from underlying NaiveDate representation. Returns the weekday number where monday = 0 and sunday = 6
This is supported on crate feature temporal
only.
temporal
only.Returns the ISO week number starting from 1. The return value ranges from 1 to 53. (The last week of year differs by years.)
This is supported on crate feature temporal
only.
temporal
only.Extract day from underlying NaiveDate representation. Returns the day of month starting from 1.
The return value ranges from 1 to 31. (The last day of month differs by months.)
This is supported on crate feature temporal
only.
temporal
only.Returns the day of year starting from 1.
The return value ranges from 1 to 366. (The last day of year differs by years.)
This is supported on crate feature temporal
only.
temporal
only.Format Date32 with a fmt
rule. See chrono strftime/strptime.
This is an iterator over a ListChunked that save allocations.
A Series is:
1. Arc
The ArrayRef we indicated with 3. will be updated during iteration. The Series will be pinned in memory, saving an allocation for
- Arc<..>
- Vec<…>
Warning
Though memory safe in the sense that it will not read unowned memory, UB, or memory leaks
this function still needs precautions. The returned should never be cloned or taken longer
than a single iteration, as every call on next
of the iterator will change the contents of
that Series.
pub fn apply_amortized<'a, F>(&'a self, f: F) -> Self where
F: Fn(UnsafeSeries<'a>) -> Series + Copy,
pub fn apply_amortized<'a, F>(&'a self, f: F) -> Self where
F: Fn(UnsafeSeries<'a>) -> Series + Copy,
Apply a closure F
elementwise.
Get a reference to the mapping of categorical types to the string values.
Get the index of the first non null value in this ChunkedArray.
Get the buffer of bits representing null values
Shrink the capacity of this array to fit it’s length.
Series to ChunkedArray
Unique id representing the number of chunks
Returns true if contains a single chunk and has no null values
Count the null values.
Append arrow array in place.
let mut array = Int32Chunked::new_from_slice("array", &[1, 2]);
let array_2 = Int32Chunked::new_from_slice("2nd", &[3]);
array.append(&array_2);
assert_eq!(Vec::from(&array), [Some(1), Some(2), Some(3)])
Slice the array. The chunks are reallocated the underlying data slices are zero copy.
When offset is negative it will be counted from the end of the array. This method will never error, and will slice the best match when offset, or length is out of bounds
Get a mask of the null values.
Get a mask of the valid values.
Create a new ChunkedArray from existing chunks.
Create a new ChunkedArray by taking ownership of the AlignedVec. This operation is zero copy.
pub fn new_from_owned_with_null_bitmap(
name: &str,
values: AlignedVec<T::Native>,
buffer: Option<Bitmap>
) -> Self
pub fn new_from_owned_with_null_bitmap(
name: &str,
values: AlignedVec<T::Native>,
buffer: Option<Bitmap>
) -> Self
Nullify values in slice with an existing null bitmap
Get slices of the underlying arrow data. NOTE: null values should be taken into account by the user of these slices as they are handled separately
pub fn into_no_null_iter(
&self
) -> impl Iterator<Item = T::Native> + '_ + Send + Sync + ExactSizeIterator + DoubleEndedIterator + TrustedLen
If cont_slice is successful a closure is mapped over the elements.
Example
use polars_core::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 PolarsIterator<Item = Option<T::Native>> + 'a>, F> where
F: Fn(Option<T::Native>) -> B,
pub fn map_null_checks<'a, B, F>(
&'a self,
f: F
) -> Map<Box<dyn PolarsIterator<Item = Option<T::Native>> + 'a>, F> where
F: Fn(Option<T::Native>) -> B,
If cont_slice fails we can fallback on an iterator with null checks and map a closure over the elements.
Example
use polars_core::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()
}
}
If cont_slice is successful a closure can be applied as aggregation
Example
use polars_core::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,
pub fn fold_null_checks<F, B>(&self, init: B, f: F) -> B where
F: Fn(B, Option<T::Native>) -> B,
If cont_slice fails we can fallback on an iterator with null checks and a closure for aggregation
Example
use polars_core::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
}
})
}
}
Get the inner data type of the list.
impl<T> ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Num + NumCast + Sub<Output = T::Native> + Div<Output = T::Native>,
ChunkedArray<T>: IntoSeries,
impl<T> ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Num + NumCast + Sub<Output = T::Native> + Div<Output = T::Native>,
ChunkedArray<T>: IntoSeries,
We cannot override the left hand side behaviour. So we create a trait LhsNumOps. This allows for 1.add(&Series)
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,
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,
impl<T, N> Add<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Add<Output = T::Native>,
impl<T, N> Add<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Add<Output = T::Native>,
impl<T, N> Add<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Add<Output = T::Native>,
impl<T, N> Add<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Add<Output = T::Native>,
Performs the conversion.
Performs the conversion.
impl<T> ChunkAgg<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
impl<T> ChunkAgg<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
Aggregate the sum of the ChunkedArray.
Returns None
if the array is empty or only contains null values. Read more
Returns the maximum value in the array, according to the natural order.
Returns None
if the array is empty or only contains null values. Read more
Returns the mean value in the array.
Returns None
if the array is empty or only contains null values. Read more
Returns the mean value in the array.
Returns None
if the array is empty or only contains null values. Read more
impl<T> ChunkAggSeries for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
ChunkedArray<T>: IntoSeries,
impl<T> ChunkAggSeries for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
ChunkedArray<T>: IntoSeries,
Get the sum of the ChunkedArray as a new Series of length 1.
Get the max of the ChunkedArray as a new Series of length 1.
Get the min of the ChunkedArray as a new Series of length 1.
Get the mean of the ChunkedArray as a new Series of length 1.
Get the median of the ChunkedArray as a new Series of length 1.
Get the quantile of the ChunkedArray as a new Series of length 1.
Get a single value. Beware this is slow. If you need to use this slightly performant, cast Categorical to UInt32 Read more
Get a single value. Beware this is slow.
impl<'a, T> ChunkApply<'a, <T as PolarsPrimitiveType>::Native, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
impl<'a, T> ChunkApply<'a, <T as PolarsPrimitiveType>::Native, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
fn apply_cast_numeric<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(T::Native) -> S::Native + Copy,
S: PolarsNumericType,
fn apply_cast_numeric<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(T::Native) -> S::Native + Copy,
S: PolarsNumericType,
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. Read more
fn branch_apply_cast_numeric_no_null<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Option<T::Native>) -> S::Native,
S: PolarsNumericType,
fn branch_apply_cast_numeric_no_null<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(Option<T::Native>) -> S::Native,
S: PolarsNumericType,
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. Read more
Apply a closure elementwise including null values.
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.
impl<T> ChunkApplyKernel<PrimitiveArray<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsNumericType,
impl<T> ChunkApplyKernel<PrimitiveArray<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsNumericType,
Apply kernel and return result as a new ChunkedArray.
fn apply_kernel_cast<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(&PrimitiveArray<T::Native>) -> ArrayRef,
S: PolarsDataType,
fn apply_kernel_cast<F, S>(&self, f: F) -> ChunkedArray<S> where
F: Fn(&PrimitiveArray<T::Native>) -> ArrayRef,
S: PolarsDataType,
Apply a kernel that outputs an array of different type.
Cast ChunkedArray<T>
to ChunkedArray<N>
Check for equality and regard missing values as equal.
Check for equality.
Check for inequality.
Greater than comparison.
Greater than or equal comparison.
Less than comparison.
Less than or equal comparison
Check for equality and regard missing values as equal.
Check for equality.
Check for inequality.
Greater than comparison.
Greater than or equal comparison.
Less than comparison.
Less than or equal comparison
impl<T> ChunkCompare<&'_ ChunkedArray<T>> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumComp + Simd8,
impl<T> ChunkCompare<&'_ ChunkedArray<T>> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumComp + Simd8,
Check for equality and regard missing values as equal.
Check for equality.
Check for inequality.
Greater than comparison.
Greater than or equal comparison.
Less than comparison.
Less than or equal comparison
Check for equality and regard missing values as equal.
Check for equality.
Check for inequality.
Greater than comparison.
Greater than or equal comparison.
Less than comparison.
Less than or equal comparison
impl<T, Rhs> ChunkCompare<Rhs> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast + NumComp + Simd8,
Rhs: NumComp + ToPrimitive,
impl<T, Rhs> ChunkCompare<Rhs> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast + NumComp + Simd8,
Rhs: NumComp + ToPrimitive,
Check for equality and regard missing values as equal.
Check for equality.
Check for inequality.
Greater than comparison.
Greater than or equal comparison.
Less than comparison.
Less than or equal comparison
impl<T> ChunkCumAgg<T> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Bounded + PartialOrd + AddAssign + Add<Output = T::Native>,
ChunkedArray<T>: FromIterator<Option<T::Native>>,
impl<T> ChunkCumAgg<T> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Bounded + PartialOrd + AddAssign + Add<Output = T::Native>,
ChunkedArray<T>: FromIterator<Option<T::Native>>,
Get an array with the cumulative max computed at every element
Get an array with the cumulative min computed at every element
Get an array with the cumulative sum computed at every element
impl<T> ChunkExpandAtIndex<T> for ChunkedArray<T> where
ChunkedArray<T>: ChunkFull<T::Native> + TakeRandom<Item = T::Native>,
T: PolarsPrimitiveType,
impl<T> ChunkExpandAtIndex<T> for ChunkedArray<T> where
ChunkedArray<T>: ChunkFull<T::Native> + TakeRandom<Item = T::Native>,
T: PolarsPrimitiveType,
Create a new ChunkedArray filled with values at that index.
impl<T> ChunkFillNull for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd + One + Bounded + Add<Output = T::Native> + Div<Output = T::Native>,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
impl<T> ChunkFillNull for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd + One + Bounded + Add<Output = T::Native> + Div<Output = T::Native>,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
Replace None values with one of the following strategies: Read more
impl<T> ChunkFillNullValue<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Add<Output = T::Native> + PartialOrd + Div<Output = T::Native> + Num + NumCast,
impl<T> ChunkFillNullValue<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Add<Output = T::Native> + PartialOrd + Div<Output = T::Native> + Num + NumCast,
Replace None values with a give value T
.
Filter values in the ChunkedArray with a boolean mask. Read more
impl<T> ChunkFull<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> ChunkFull<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> ChunkPeaks for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumComp + Zero + Simd8,
impl<T> ChunkPeaks for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumComp + Zero + Simd8,
Get a boolean mask of the local maximum peaks.
Get a boolean mask of the local minimum peaks.
impl<T> ChunkReverse<T> for ChunkedArray<T> where
T: PolarsNumericType,
ChunkedArray<T>: ChunkOps,
impl<T> ChunkReverse<T> for ChunkedArray<T> where
T: PolarsNumericType,
ChunkedArray<T>: ChunkOps,
Return a reversed version of this array.
impl<T> ChunkRollApply for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Zero,
Self: IntoSeries,
impl<T> ChunkRollApply for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Zero,
Self: IntoSeries,
impl<'a, T> ChunkSet<'a, <T as PolarsPrimitiveType>::Native, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
impl<'a, T> ChunkSet<'a, <T as PolarsPrimitiveType>::Native, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
fn set_at_idx<I: IntoIterator<Item = usize>>(
&'a self,
idx: I,
value: Option<T::Native>
) -> Result<Self>
fn set_at_idx<I: IntoIterator<Item = usize>>(
&'a self,
idx: I,
value: Option<T::Native>
) -> Result<Self>
Set the values at indexes idx
to some optional value Option<T>
. Read more
fn set_at_idx_with<I: IntoIterator<Item = usize>, F>(
&'a self,
idx: I,
f: F
) -> Result<Self> where
F: Fn(Option<T::Native>) -> Option<T::Native>,
fn set_at_idx_with<I: IntoIterator<Item = usize>, F>(
&'a self,
idx: I,
f: F
) -> Result<Self> where
F: Fn(Option<T::Native>) -> Option<T::Native>,
Set the values at indexes idx
by applying a closure to these values. Read more
Set the values where the mask evaluates to true
to some optional value Option<T>
. Read more
impl<T> ChunkShiftFill<T, Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Copy,
impl<T> ChunkShiftFill<T, Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Copy,
Shift the values by a given period and fill the parts that will be empty due to this operation
with fill_value
. Read more
Panics
This function is very opinionated.
We assume that all numeric Series
are of the same type, if not it will panic
Returned a sorted ChunkedArray
.
Sort this array in place.
Retrieve the indexes needed to sort this array.
unsafe fn take_unchecked<I, INulls>(
&self,
indices: TakeIdx<'_, I, INulls>
) -> Self where
Self: Sized,
I: TakeIterator,
INulls: TakeIteratorNulls,
unsafe fn take_unchecked<I, INulls>(
&self,
indices: TakeIdx<'_, I, INulls>
) -> Self where
Self: Sized,
I: TakeIterator,
INulls: TakeIteratorNulls,
Take values from ChunkedArray by index. Read more
fn take<I, INulls>(&self, indices: TakeIdx<'_, I, INulls>) -> Result<Self> where
Self: Sized,
I: TakeIterator,
INulls: TakeIteratorNulls,
fn take<I, INulls>(&self, indices: TakeIdx<'_, I, INulls>) -> Result<Self> where
Self: Sized,
I: TakeIterator,
INulls: TakeIteratorNulls,
Take values from ChunkedArray by index. Note that the iterator will be cloned, so prefer an iterator that takes the owned memory by reference. Read more
Traverse and collect every nth element in a new array.
impl<T> ChunkUnique<T> for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: Hash + Eq + NumCast,
ChunkedArray<T>: ChunkOps + IntoSeries,
impl<T> ChunkUnique<T> for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: Hash + Eq + NumCast,
ChunkedArray<T>: ChunkOps + IntoSeries,
Get first index of the unique values in a ChunkedArray
.
This Vec is sorted. Read more
Get a mask of all the unique values.
Get a mask of all the duplicated values.
Count the unique values.
apply a rolling sum (moving sum) over the values in this array.
a window of length window_size
will traverse the array. the values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector. the resulting
values will be aggregated to their sum. Read more
Apply a rolling mean (moving mean) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector. The resulting
values will be aggregated to their mean. Read more
Apply a rolling min (moving min) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector. The resulting
values will be aggregated to their min. Read more
Apply a rolling max (moving max) over the values in this array.
A window of length window_size
will traverse the array. The values that fill this window
will (optionally) be multiplied with the weights given by the weight
vector. The resulting
values will be aggregated to their max. Read more
impl<T> ChunkWindowCustom<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Zero + Bounded + NumCast + Div<Output = T::Native> + Mul<Output = T::Native> + PartialOrd + One + Copy,
impl<T> ChunkWindowCustom<<T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Zero + Bounded + NumCast + Div<Output = T::Native> + Mul<Output = T::Native> + PartialOrd + One + Copy,
This is similar to how rolling_min, sum, max, mean is implemented. It takes a window, weights it and applies a fold aggregator
Create a new ChunkedArray with values from self where the mask evaluates true
and values
from other
where the mask evaluates false
Read more
Performs the conversion.
Performs the conversion.
impl<'a> From<&'a ChunkedArray<UInt32Type>> for TakeIdx<'a, Dummy<usize>, Dummy<Option<usize>>>
impl<'a> From<&'a ChunkedArray<UInt32Type>> for TakeIdx<'a, Dummy<usize>, Dummy<Option<usize>>>
Conversion from UInt32Chunked to Unchecked TakeIdx
Performs the conversion.
From trait
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
impl<T: PolarsNumericType> From<PrimitiveArray<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T>
impl<T: PolarsNumericType> From<PrimitiveArray<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T>
Performs the conversion.
impl<T> FromIterator<(MutableBuffer<<T as PolarsPrimitiveType>::Native>, Option<Bitmap>)> for ChunkedArray<T> where
T: PolarsNumericType,
impl<T> FromIterator<(MutableBuffer<<T as PolarsPrimitiveType>::Native>, Option<Bitmap>)> for ChunkedArray<T> where
T: PolarsNumericType,
fn from_iter<I: IntoIterator<Item = (AlignedVec<T::Native>, Option<Bitmap>)>>(
iter: I
) -> Self
fn from_iter<I: IntoIterator<Item = (AlignedVec<T::Native>, Option<Bitmap>)>>(
iter: I
) -> Self
Creates a value from an iterator. Read more
impl<T> FromIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> FromIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
FromIterator trait
impl<T> FromParallelIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> FromParallelIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
Creates an instance of the collection from the parallel iterator par_iter
. Read more
impl<T> FromTrustedLenIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> FromTrustedLenIterator<Option<<T as PolarsPrimitiveType>::Native>> for ChunkedArray<T> where
T: PolarsPrimitiveType,
fn from_iter_trusted_length<I: IntoIterator<Item = Option<bool>>>(
iter: I
) -> Self where
I::IntoIter: TrustedLen,
impl<T> Interpolate for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Sub<Output = T::Native> + Mul<Output = T::Native> + Add<Output = T::Native> + Div<Output = T::Native> + FromPrimitive + Zero,
impl<T> Interpolate for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Sub<Output = T::Native> + Mul<Output = T::Native> + Add<Output = T::Native> + Div<Output = T::Native> + FromPrimitive + Zero,
Create the tuples need for a groupby operation. * The first value in the tuple is the first index of the group. * The second value in the tuple is are the indexes of the groups including the first value. Read more
type TakeRandom = TakeRandBranch3<NumTakeRandomCont<'a, T::Native>, NumTakeRandomSingleChunk<'a, T>, NumTakeRandomChunked<'a, T>>
Create a type that implements TakeRandom
.
is_first
only.is_in
only.Check if elements of this array are in the right Series, or List values of the right Series.
impl<T, N> Mul<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Mul<Output = T::Native>,
impl<T, N> Mul<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Mul<Output = T::Native>,
impl<T, N> Mul<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Mul<Output = T::Native>,
impl<T, N> Mul<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Mul<Output = T::Native>,
impl<T> NewChunkedArray<T, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsPrimitiveType,
impl<T> NewChunkedArray<T, <T as PolarsPrimitiveType>::Native> for ChunkedArray<T> where
T: PolarsPrimitiveType,
Create a new ChunkedArray from an iterator.
fn new_from_opt_iter(
name: &str,
it: impl Iterator<Item = Option<T::Native>>
) -> ChunkedArray<T>
fn new_from_opt_iter(
name: &str,
it: impl Iterator<Item = Option<T::Native>>
) -> ChunkedArray<T>
Create a new ChunkedArray from an iterator.
impl<T> NumOpsDispatch for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Rem<Output = T::Native> + Zero + One,
ChunkedArray<T>: IntoSeries,
impl<T> NumOpsDispatch for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: Add<Output = T::Native> + Sub<Output = T::Native> + Mul<Output = T::Native> + Div<Output = T::Native> + Rem<Output = T::Native> + Zero + One,
ChunkedArray<T>: IntoSeries,
impl<T> NumOpsDispatchChecked for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: CheckedDiv<Output = T::Native> + Zero + One,
ChunkedArray<T>: IntoSeries,
impl<T> NumOpsDispatchChecked for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: CheckedDiv<Output = T::Native> + Zero + One,
ChunkedArray<T>: IntoSeries,
Checked integer division. Computes self / rhs, returning None if rhs == 0 or the division results in overflow.
repeat_by
only.Repeat the values n
times, where n
is determined by the values in by
.
impl<T, N> Sub<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Sub<Output = T::Native>,
impl<T, N> Sub<N> for &ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Sub<Output = T::Native>,
impl<T, N> Sub<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Sub<Output = T::Native>,
impl<T, N> Sub<N> for ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NumCast,
N: Num + ToPrimitive,
T::Native: Sub<Output = T::Native>,
impl<'a, T> TakeRandom for &'a ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType,
impl<'a, T> TakeRandom for &'a ChunkedArray<T> where
T: PolarsNumericType,
T::Native: NativeType,
impl<T> ToDummies<T> for ChunkedArray<T> where
T: PolarsIntegerType + Sync,
T::Native: Hash + Eq + Display + NumCast,
ChunkedArray<T>: ChunkOps + ChunkCompare<T::Native> + ChunkUnique<T>,
impl<T> ToDummies<T> for ChunkedArray<T> where
T: PolarsIntegerType + Sync,
T::Native: Hash + Eq + Display + NumCast,
ChunkedArray<T>: ChunkOps + ChunkCompare<T::Native> + ChunkUnique<T>,
impl<T> VarAggSeries for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
impl<T> VarAggSeries for ChunkedArray<T> where
T: PolarsIntegerType,
T::Native: NativeType + PartialOrd + Num + NumCast + Zero + Simd,
<T::Native as Simd>::Simd: Add<Output = <T::Native as Simd>::Simd> + Sum<T::Native> + SimdOrd<T::Native>,
Get the variance of the ChunkedArray as a new Series of length 1.
Get the standard deviation of the ChunkedArray as a new Series of length 1.
Compute the hash for all values in the array. Read more
impl<T> ZipOuterJoinColumn for ChunkedArray<T> where
T: PolarsIntegerType,
ChunkedArray<T>: IntoSeries,
impl<T> ZipOuterJoinColumn for ChunkedArray<T> where
T: PolarsIntegerType,
ChunkedArray<T>: IntoSeries,
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
Mutably borrows from an owned value. Read more