pub struct Logical<Logical: PolarsDataType, Physical: PolarsDataType>(pub ChunkedArray<Physical>, _, pub Option<DataType>);
Expand description
Maps a logical type to a chunked array implementation of the physical type. This saves a lot of compiler bloat and allows us to reuse functionality.
Tuple Fields§
§0: ChunkedArray<Physical>
§2: Option<DataType>
Implementations§
Source§impl Logical<DecimalType, Int128Type>
impl Logical<DecimalType, Int128Type>
Source§impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>
pub fn new_logical<J: PolarsDataType>(ca: ChunkedArray<T>) -> Logical<J, T>
Source§impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>where
Self: LogicalType,
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>where
Self: LogicalType,
Methods from Deref<Target = ChunkedArray<T>>§
pub fn sum(&self) -> Option<IdxSize>
pub fn min(&self) -> Option<bool>
pub fn max(&self) -> Option<bool>
pub fn mean(&self) -> Option<f64>
pub fn max_binary(&self) -> Option<&[u8]>
pub fn min_binary(&self) -> Option<&[u8]>
Sourcepub fn append(&mut self, other: &Self) -> PolarsResult<()>
pub fn append(&mut self, other: &Self) -> PolarsResult<()>
Append in place. This is done by adding the chunks of other
to this ChunkedArray
.
See also extend
for appends to the underlying memory
Sourcepub fn append_owned(&mut self, other: Self) -> PolarsResult<()>
pub fn append_owned(&mut self, other: Self) -> PolarsResult<()>
Append in place. This is done by adding the chunks of other
to this ChunkedArray
.
See also extend
for appends to the underlying memory
Sourcepub fn apply_nonnull_values_generic<'a, U, K, F>(
&'a self,
dtype: DataType,
op: F,
) -> ChunkedArray<U>where
U: PolarsDataType,
F: FnMut(T::Physical<'a>) -> K,
U::Array: ArrayFromIterDtype<K> + ArrayFromIterDtype<Option<K>>,
pub fn apply_nonnull_values_generic<'a, U, K, F>(
&'a self,
dtype: DataType,
op: F,
) -> ChunkedArray<U>where
U: PolarsDataType,
F: FnMut(T::Physical<'a>) -> K,
U::Array: ArrayFromIterDtype<K> + ArrayFromIterDtype<Option<K>>,
Applies a function only to the non-null elements, propagating nulls.
Sourcepub fn try_apply_nonnull_values_generic<'a, U, K, F, E>(
&'a self,
op: F,
) -> Result<ChunkedArray<U>, E>where
U: PolarsDataType,
F: FnMut(T::Physical<'a>) -> Result<K, E>,
U::Array: ArrayFromIter<K> + ArrayFromIter<Option<K>>,
pub fn try_apply_nonnull_values_generic<'a, U, K, F, E>(
&'a self,
op: F,
) -> Result<ChunkedArray<U>, E>where
U: PolarsDataType,
F: FnMut(T::Physical<'a>) -> Result<K, E>,
U::Array: ArrayFromIter<K> + ArrayFromIter<Option<K>>,
Applies a function only to the non-null elements, propagating nulls.
pub fn apply_into_string_amortized<'a, F>(&'a self, f: F) -> StringChunked
pub fn try_apply_into_string_amortized<'a, F, E>( &'a self, f: F, ) -> Result<StringChunked, E>
Sourcepub fn cast_and_apply_in_place<F, S>(&self, f: F) -> ChunkedArray<S>
pub fn cast_and_apply_in_place<F, S>(&self, f: F) -> ChunkedArray<S>
Cast a numeric array to another numeric data type and apply a function in place. This saves an allocation.
pub fn apply_mut<F>(&mut self, f: F)
pub fn apply_mut<'a, F>(&'a self, f: F) -> Self
pub fn apply_mut<'a, F>(&'a self, f: F) -> Self
Sourcepub unsafe fn apply_views<F: FnMut(View, &str) -> View + Copy>(
&self,
update_view: F,
) -> Self
pub unsafe fn apply_views<F: FnMut(View, &str) -> View + Copy>( &self, update_view: F, ) -> Self
§Safety
Update the views. All invariants of the views apply.
pub fn apply_as_ints<F>(&self, f: F) -> Series
pub fn apply_as_ints<F>(&self, f: F) -> Series
pub fn num_trues(&self) -> usize
pub fn num_falses(&self) -> usize
Sourcepub fn null_count(&self) -> usize
pub fn null_count(&self) -> usize
Return the number of null values in the ChunkedArray.
Sourcepub unsafe fn set_null_count(&mut self, null_count: usize)
pub unsafe fn set_null_count(&mut self, null_count: usize)
Set the null count directly.
This can be useful after mutably adjusting the validity of the underlying arrays.
§Safety
The new null count must match the total null count of the underlying arrays.
Sourcepub fn rechunk(&self) -> Cow<'_, Self>
pub fn rechunk(&self) -> Cow<'_, Self>
Rechunks this ChunkedArray, returning a new Cow::Owned ChunkedArray if it was rechunked or simply a Cow::Borrowed of itself if it was already a single chunk.
Sourcepub fn rechunk_mut(&mut self)
pub fn rechunk_mut(&mut self)
Rechunks this ChunkedArray in-place.
pub fn rechunk_validity(&self) -> Option<Bitmap>
pub fn with_validities(&mut self, validities: &[Option<Bitmap>])
Sourcepub fn split_at(&self, offset: i64) -> (Self, Self)
pub fn split_at(&self, offset: i64) -> (Self, Self)
Split 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
Sourcepub fn slice(&self, offset: i64, length: usize) -> Self
pub fn slice(&self, offset: i64, length: usize) -> Self
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
Sourcepub fn limit(&self, num_elements: usize) -> Selfwhere
Self: Sized,
pub fn limit(&self, num_elements: usize) -> Selfwhere
Self: Sized,
Take a view of top n elements
Sourcepub fn head(&self, length: Option<usize>) -> Selfwhere
Self: Sized,
pub fn head(&self, length: Option<usize>) -> Selfwhere
Self: Sized,
Get the head of the ChunkedArray
Sourcepub fn tail(&self, length: Option<usize>) -> Selfwhere
Self: Sized,
pub fn tail(&self, length: Option<usize>) -> Selfwhere
Self: Sized,
Get the tail of the ChunkedArray
Sourcepub fn prune_empty_chunks(&mut self)
pub fn prune_empty_chunks(&mut self)
Remove empty chunks.
Sourcepub fn to_decimal(&self, infer_length: usize) -> PolarsResult<Series>
Available on crate feature dtype-decimal
only.
pub fn to_decimal(&self, infer_length: usize) -> PolarsResult<Series>
dtype-decimal
only.Convert an StringChunked
to a Series
of DataType::Decimal
.
Scale needed for the decimal type are inferred. Parsing is not strict.
Scale inference assumes that all tested strings are well-formed numbers,
and may produce unexpected results for scale if this is not the case.
If the decimal precision
and scale
are already known, consider
using the cast
method.
Sourcepub fn extend(&mut self, other: &Self) -> PolarsResult<()>
pub fn extend(&mut self, other: &Self) -> PolarsResult<()>
Extend the memory backed by this array with the values from other
.
Different from ChunkedArray::append
which adds chunks to this ChunkedArray
extend
appends the data from other
to the underlying PrimitiveArray
and thus may cause a reallocation.
However if this does not cause a reallocation, the resulting data structure will not have any extra chunks and thus will yield faster queries.
Prefer extend
over append
when you want to do a query after a single append. For instance during
online operations where you add n
rows and rerun a query.
Prefer append
over extend
when you want to append many times before doing a query. For instance
when you read in multiple files and when to store them in a single DataFrame
.
In the latter case finish the sequence of append
operations with a rechunk
.
pub fn for_each<'a, F>(&'a self, op: F)
Sourcepub fn is_null(&self) -> BooleanChunked
pub fn is_null(&self) -> BooleanChunked
Get a mask of the null values.
Sourcepub fn is_not_null(&self) -> BooleanChunked
pub fn is_not_null(&self) -> BooleanChunked
Get a mask of the valid values.
Sourcepub fn rolling_map_float<F>(
&self,
window_size: usize,
f: F,
) -> PolarsResult<Self>
Available on crate feature rolling_window
only.
pub fn rolling_map_float<F>( &self, window_size: usize, f: F, ) -> PolarsResult<Self>
rolling_window
only.Apply a rolling custom function. This is pretty slow because of dynamic dispatch.
Sourcepub unsafe fn to_string_unchecked(&self) -> StringChunked
pub unsafe fn to_string_unchecked(&self) -> StringChunked
§Safety
String is not validated
pub fn as_binary(&self) -> BinaryChunked
Sourcepub fn any(&self) -> bool
pub fn any(&self) -> bool
Returns whether any of the values in the column are true
.
Null values are ignored.
Sourcepub fn all(&self) -> bool
pub fn all(&self) -> bool
Returns whether all values in the array are true
.
Null values are ignored.
Sourcepub fn any_kleene(&self) -> Option<bool>
pub fn any_kleene(&self) -> Option<bool>
Returns whether any of the values in the column are true
.
The output is unknown (None
) if the array contains any null values and
no true
values.
Sourcepub fn all_kleene(&self) -> Option<bool>
pub fn all_kleene(&self) -> Option<bool>
Returns whether all values in the column are true
.
The output is unknown (None
) if the array contains any null values and
no false
values.
pub fn is_nan(&self) -> BooleanChunked
pub fn is_not_nan(&self) -> BooleanChunked
pub fn is_finite(&self) -> BooleanChunked
pub fn is_infinite(&self) -> BooleanChunked
Sourcepub fn none_to_nan(&self) -> Self
pub fn none_to_nan(&self) -> Self
Convert missing values to NaN
values.
pub fn to_canonical(&self) -> Self
pub fn par_iter(&self) -> impl ParallelIterator<Item = Option<Series>> + '_
pub fn par_iter_indexed( &mut self, ) -> impl IndexedParallelIterator<Item = Option<Series>> + '_
pub fn par_iter_indexed( &self, ) -> impl IndexedParallelIterator<Item = Option<&str>>
pub fn par_iter(&self) -> impl ParallelIterator<Item = Option<&str>> + '_
pub fn iter(&self) -> impl PolarsIterator<Item = Option<T::Physical<'_>>>
Sourcepub fn to_ndarray(&self) -> PolarsResult<ArrayView1<'_, T::Native>>
Available on crate feature ndarray
only.
pub fn to_ndarray(&self) -> PolarsResult<ArrayView1<'_, T::Native>>
ndarray
only.If data is aligned in a single chunk and has no Null values a zero copy view is returned as an ndarray
Sourcepub fn to_ndarray<N>(&self) -> PolarsResult<Array2<N::Native>>where
N: PolarsNumericType,
Available on crate feature ndarray
only.
pub fn to_ndarray<N>(&self) -> PolarsResult<Array2<N::Native>>where
N: PolarsNumericType,
ndarray
only.If all nested Series
have the same length, a 2 dimensional ndarray::Array
is returned.
Sourcepub fn amortized_iter(
&self,
) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
Available on crate feature dtype-array
only.
pub fn amortized_iter( &self, ) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
dtype-array
only.This is an iterator over a ArrayChunked
that save allocations.
A Series is:
1. Arc<ChunkedArray>
ChunkedArray is:
2. Vec< 3. ArrayRef>
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.
§Safety
The lifetime of AmortSeries is bound to the iterator. Keeping it alive longer than the iterator is UB.
Sourcepub fn amortized_iter_with_name(
&self,
name: PlSmallStr,
) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
Available on crate feature dtype-array
only.
pub fn amortized_iter_with_name( &self, name: PlSmallStr, ) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
dtype-array
only.This is an iterator over a ArrayChunked
that save allocations.
A Series is:
1. Arc<ChunkedArray>
ChunkedArray is:
2. Vec< 3. ArrayRef>
The ArrayRef we indicated with 3. will be updated during iteration. The Series will be pinned in memory, saving an allocation for
- Arc<..>
- Vec<…>
If the returned AmortSeries
is cloned, the local copy will be replaced and a new container
will be set.
pub fn try_apply_amortized_to_list<F>(&self, f: F) -> PolarsResult<ListChunked>
dtype-array
only.Sourcepub unsafe fn apply_amortized_same_type<F>(&self, f: F) -> Self
Available on crate feature dtype-array
only.
pub unsafe fn apply_amortized_same_type<F>(&self, f: F) -> Self
dtype-array
only.Apply a closure F
to each array.
§Safety
Return series of F
must has the same dtype and number of elements as input.
Sourcepub unsafe fn try_apply_amortized_same_type<F>(
&self,
f: F,
) -> PolarsResult<Self>
Available on crate feature dtype-array
only.
pub unsafe fn try_apply_amortized_same_type<F>( &self, f: F, ) -> PolarsResult<Self>
dtype-array
only.Try apply a closure F
to each array.
§Safety
Return series of F
must has the same dtype and number of elements as input if it is Ok.
Sourcepub unsafe fn zip_and_apply_amortized_same_type<'a, T, F>(
&'a self,
ca: &'a ChunkedArray<T>,
f: F,
) -> Self
Available on crate feature dtype-array
only.
pub unsafe fn zip_and_apply_amortized_same_type<'a, T, F>( &'a self, ca: &'a ChunkedArray<T>, f: F, ) -> Self
dtype-array
only.Zip with a ChunkedArray
then apply a binary function F
elementwise.
§Safety
Sourcepub fn apply_amortized_generic<F, K, V>(&self, f: F) -> ChunkedArray<V>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> Option<K> + Copy,
V::Array: ArrayFromIter<Option<K>>,
Available on crate feature dtype-array
only.
pub fn apply_amortized_generic<F, K, V>(&self, f: F) -> ChunkedArray<V>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> Option<K> + Copy,
V::Array: ArrayFromIter<Option<K>>,
dtype-array
only.Apply a closure F
elementwise.
Sourcepub fn try_apply_amortized_generic<F, K, V>(
&self,
f: F,
) -> PolarsResult<ChunkedArray<V>>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> PolarsResult<Option<K>> + Copy,
V::Array: ArrayFromIter<Option<K>>,
Available on crate feature dtype-array
only.
pub fn try_apply_amortized_generic<F, K, V>(
&self,
f: F,
) -> PolarsResult<ChunkedArray<V>>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> PolarsResult<Option<K>> + Copy,
V::Array: ArrayFromIter<Option<K>>,
dtype-array
only.Try apply a closure F
elementwise.
pub fn for_each_amortized<F>(&self, f: F)
dtype-array
only.Sourcepub fn inner_dtype(&self) -> &DataType
Available on crate feature dtype-array
only.
pub fn inner_dtype(&self) -> &DataType
dtype-array
only.Get the inner data type of the fixed size list.
pub fn width(&self) -> usize
dtype-array
only.Sourcepub unsafe fn to_logical(&mut self, inner_dtype: DataType)
Available on crate feature dtype-array
only.
pub unsafe fn to_logical(&mut self, inner_dtype: DataType)
dtype-array
only.§Safety
The caller must ensure that the logical type given fits the physical type of the array.
Sourcepub fn to_physical_repr(&self) -> Cow<'_, ArrayChunked>
Available on crate feature dtype-array
only.
pub fn to_physical_repr(&self) -> Cow<'_, ArrayChunked>
dtype-array
only.Convert the datatype of the array into the physical datatype.
Sourcepub unsafe fn from_physical_unchecked(
&self,
to_inner_dtype: DataType,
) -> PolarsResult<Self>
Available on crate feature dtype-array
only.
pub unsafe fn from_physical_unchecked( &self, to_inner_dtype: DataType, ) -> PolarsResult<Self>
dtype-array
only.Convert a non-logical ArrayChunked
back into a logical ArrayChunked
without casting.
§Safety
This can lead to invalid memory access in downstream code.
Sourcepub fn get_inner(&self) -> Series
Available on crate feature dtype-array
only.
pub fn get_inner(&self) -> Series
dtype-array
only.Get the inner values as Series
Sourcepub fn apply_to_inner(
&self,
func: &dyn Fn(Series) -> PolarsResult<Series>,
) -> PolarsResult<ArrayChunked>
Available on crate feature dtype-array
only.
pub fn apply_to_inner( &self, func: &dyn Fn(Series) -> PolarsResult<Series>, ) -> PolarsResult<ArrayChunked>
dtype-array
only.Ignore the list indices and apply func
to the inner type as Series
.
Sourcepub fn get_leaf_array(&self) -> Series
Available on crate feature dtype-array
only.
pub fn get_leaf_array(&self) -> Series
dtype-array
only.Recurse nested types until we are at the leaf array.
pub fn to_bytes_hashes<'a>( &'a self, multithreaded: bool, hb: PlRandomState, ) -> Vec<Vec<BytesHash<'a>>>
Sourcepub unsafe fn with_chunks(&self, chunks: Vec<ArrayRef>) -> Self
pub unsafe fn with_chunks(&self, chunks: Vec<ArrayRef>) -> Self
§Safety
The Arrow datatype of all chunks must match the PolarsDataType
T
.
Sourcepub fn amortized_iter(
&self,
) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
pub fn amortized_iter( &self, ) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
This is an iterator over a ListChunked
that saves allocations.
A Series is:
1. Arc<ChunkedArray>
ChunkedArray is:
2. Vec< 3. ArrayRef>
The ArrayRef we indicated with 3. will be updated during iteration. The Series will be pinned in memory, saving an allocation for
- Arc<..>
- Vec<…>
If the returned AmortSeries
is cloned, the local copy will be replaced and a new container
will be set.
Sourcepub fn amortized_iter_with_name(
&self,
name: PlSmallStr,
) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
pub fn amortized_iter_with_name( &self, name: PlSmallStr, ) -> AmortizedListIter<'_, impl Iterator<Item = Option<ArrayBox>> + '_>
See amortized_iter
.
Sourcepub fn apply_amortized_generic<F, K, V>(&self, f: F) -> ChunkedArray<V>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> Option<K> + Copy,
V::Array: ArrayFromIter<Option<K>>,
pub fn apply_amortized_generic<F, K, V>(&self, f: F) -> ChunkedArray<V>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> Option<K> + Copy,
V::Array: ArrayFromIter<Option<K>>,
Apply a closure F
elementwise.
pub fn try_apply_amortized_generic<F, K, V>(
&self,
f: F,
) -> PolarsResult<ChunkedArray<V>>where
V: PolarsDataType,
F: FnMut(Option<AmortSeries>) -> PolarsResult<Option<K>> + Copy,
V::Array: ArrayFromIter<Option<K>>,
pub fn for_each_amortized<F>(&self, f: F)
Sourcepub fn zip_and_apply_amortized<'a, T, I, F>(
&'a self,
ca: &'a ChunkedArray<T>,
f: F,
) -> Selfwhere
T: PolarsDataType,
&'a ChunkedArray<T>: IntoIterator<IntoIter = I>,
I: TrustedLen<Item = Option<T::Physical<'a>>>,
F: FnMut(Option<AmortSeries>, Option<T::Physical<'a>>) -> Option<Series>,
pub fn zip_and_apply_amortized<'a, T, I, F>(
&'a self,
ca: &'a ChunkedArray<T>,
f: F,
) -> Selfwhere
T: PolarsDataType,
&'a ChunkedArray<T>: IntoIterator<IntoIter = I>,
I: TrustedLen<Item = Option<T::Physical<'a>>>,
F: FnMut(Option<AmortSeries>, Option<T::Physical<'a>>) -> Option<Series>,
Zip with a ChunkedArray
then apply a binary function F
elementwise.
pub fn binary_zip_and_apply_amortized<'a, T, U, F>(
&'a self,
ca1: &'a ChunkedArray<T>,
ca2: &'a ChunkedArray<U>,
f: F,
) -> Selfwhere
T: PolarsDataType,
U: PolarsDataType,
F: FnMut(Option<AmortSeries>, Option<T::Physical<'a>>, Option<U::Physical<'a>>) -> Option<Series>,
pub fn try_zip_and_apply_amortized<'a, T, I, F>(
&'a self,
ca: &'a ChunkedArray<T>,
f: F,
) -> PolarsResult<Self>where
T: PolarsDataType,
&'a ChunkedArray<T>: IntoIterator<IntoIter = I>,
I: TrustedLen<Item = Option<T::Physical<'a>>>,
F: FnMut(Option<AmortSeries>, Option<T::Physical<'a>>) -> PolarsResult<Option<Series>>,
Sourcepub fn apply_amortized<F>(&self, f: F) -> Self
pub fn apply_amortized<F>(&self, f: F) -> Self
Apply a closure F
elementwise.
pub fn try_apply_amortized<F>(&self, f: F) -> PolarsResult<Self>
Sourcepub fn inner_dtype(&self) -> &DataType
pub fn inner_dtype(&self) -> &DataType
Get the inner data type of the list.
pub fn set_inner_dtype(&mut self, dtype: DataType)
pub fn set_fast_explode(&mut self)
pub fn _can_fast_explode(&self) -> bool
Sourcepub unsafe fn to_logical(&mut self, inner_dtype: DataType)
pub unsafe fn to_logical(&mut self, inner_dtype: DataType)
Set the logical type of the ListChunked
.
§Safety
The caller must ensure that the logical type given fits the physical type of the array.
Sourcepub fn to_physical_repr(&self) -> Cow<'_, ListChunked>
pub fn to_physical_repr(&self) -> Cow<'_, ListChunked>
Convert the datatype of the list into the physical datatype.
Sourcepub unsafe fn from_physical_unchecked(
&self,
to_inner_dtype: DataType,
) -> PolarsResult<ListChunked>
pub unsafe fn from_physical_unchecked( &self, to_inner_dtype: DataType, ) -> PolarsResult<ListChunked>
Convert a non-logical ListChunked
back into a logical ListChunked
without casting.
§Safety
This can lead to invalid memory access in downstream code.
Sourcepub fn apply_to_inner(
&self,
func: &dyn Fn(Series) -> PolarsResult<Series>,
) -> PolarsResult<ListChunked>
pub fn apply_to_inner( &self, func: &dyn Fn(Series) -> PolarsResult<Series>, ) -> PolarsResult<ListChunked>
Ignore the list indices and apply func
to the inner type as Series
.
pub fn rechunk_and_trim_to_normalized_offsets(&self) -> Self
Sourcepub unsafe fn get_object_unchecked(
&self,
index: usize,
) -> Option<&dyn PolarsObjectSafe>
Available on crate feature object
only.
pub unsafe fn get_object_unchecked( &self, index: usize, ) -> Option<&dyn PolarsObjectSafe>
object
only.Get a hold to an object that can be formatted or downcasted via the Any trait.
§Safety
No bounds checks
Sourcepub fn get_object(&self, index: usize) -> Option<&dyn PolarsObjectSafe>
Available on crate feature object
only.
pub fn get_object(&self, index: usize) -> Option<&dyn PolarsObjectSafe>
object
only.Get a hold to an object that can be formatted or downcasted via the Any trait.
Sourcepub fn sample_n(
&self,
n: usize,
with_replacement: bool,
shuffle: bool,
seed: Option<u64>,
) -> PolarsResult<Self>
Available on crate feature random
only.
pub fn sample_n( &self, n: usize, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PolarsResult<Self>
random
only.Sample n datapoints from this ChunkedArray
.
Sourcepub fn sample_frac(
&self,
frac: f64,
with_replacement: bool,
shuffle: bool,
seed: Option<u64>,
) -> PolarsResult<Self>
Available on crate feature random
only.
pub fn sample_frac( &self, frac: f64, with_replacement: bool, shuffle: bool, seed: Option<u64>, ) -> PolarsResult<Self>
random
only.Sample a fraction between 0.0-1.0 of this ChunkedArray
.
Sourcepub fn to_vec_null_aware(
&self,
) -> Either<Vec<T::Native>, Vec<Option<T::Native>>>
pub fn to_vec_null_aware( &self, ) -> Either<Vec<T::Native>, Vec<Option<T::Native>>>
Convert to a Vec
but don’t return Option<T::Native>
if there are no null values
Sourcepub fn unpack_series_matching_type<'a>(
&self,
series: &'a Series,
) -> PolarsResult<&'a ChunkedArray<T>>
pub fn unpack_series_matching_type<'a>( &self, series: &'a Series, ) -> PolarsResult<&'a ChunkedArray<T>>
Series to ChunkedArray<T>
pub fn unset_fast_explode_list(&mut self)
pub fn set_fast_explode_list(&mut self, value: bool)
pub fn get_fast_explode_list(&self) -> bool
pub fn get_flags(&self) -> StatisticsFlags
pub fn is_sorted_flag(&self) -> IsSorted
pub fn retain_flags_from<U: PolarsDataType>( &mut self, from: &ChunkedArray<U>, retain_flags: StatisticsFlags, )
Sourcepub fn set_sorted_flag(&mut self, sorted: IsSorted)
pub fn set_sorted_flag(&mut self, sorted: IsSorted)
Set the ‘sorted’ bit meta info.
Sourcepub fn with_sorted_flag(&self, sorted: IsSorted) -> Self
pub fn with_sorted_flag(&self, sorted: IsSorted) -> Self
Set the ‘sorted’ bit meta info.
Sourcepub fn first_non_null(&self) -> Option<usize>
pub fn first_non_null(&self) -> Option<usize>
Get the index of the first non null value in this ChunkedArray
.
Sourcepub fn last_non_null(&self) -> Option<usize>
pub fn last_non_null(&self) -> Option<usize>
Get the index of the last non null value in this ChunkedArray
.
pub fn drop_nulls(&self) -> Self
Sourcepub fn iter_validities(
&self,
) -> Map<Iter<'_, ArrayRef>, fn(&ArrayRef) -> Option<&Bitmap>> ⓘ
pub fn iter_validities( &self, ) -> Map<Iter<'_, ArrayRef>, fn(&ArrayRef) -> Option<&Bitmap>> ⓘ
Get the buffer of bits representing null values
Sourcepub fn has_nulls(&self) -> bool
pub fn has_nulls(&self) -> bool
Return if any the chunks in this ChunkedArray
have nulls.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink the capacity of this array to fit its length.
pub fn clear(&self) -> Self
Sourcepub fn chunk_lengths(&self) -> ChunkLenIter<'_>
pub fn chunk_lengths(&self) -> ChunkLenIter<'_>
Returns an iterator over the lengths of the chunks of the array.
Sourcepub unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef>
pub unsafe fn chunks_mut(&mut self) -> &mut Vec<ArrayRef>
Sourcepub fn is_optimal_aligned(&self) -> bool
pub fn is_optimal_aligned(&self) -> bool
Returns true if contains a single chunk and has no null values
Sourcepub fn dtype(&self) -> &DataType
pub fn dtype(&self) -> &DataType
Get data type of ChunkedArray
.
Sourcepub fn name(&self) -> &PlSmallStr
pub fn name(&self) -> &PlSmallStr
Name of the ChunkedArray
.
Sourcepub fn rename(&mut self, name: PlSmallStr)
pub fn rename(&mut self, name: PlSmallStr)
Rename this ChunkedArray
.
Sourcepub fn get(&self, idx: usize) -> Option<T::Physical<'_>>
pub fn get(&self, idx: usize) -> Option<T::Physical<'_>>
Get a single value from this ChunkedArray
. If the return values is None
this
indicates a NULL value.
§Panics
This function will panic if idx
is out of bounds.
Sourcepub unsafe fn get_unchecked(&self, idx: usize) -> Option<T::Physical<'_>>
pub unsafe fn get_unchecked(&self, idx: usize) -> Option<T::Physical<'_>>
Get a single value from this ChunkedArray
. If the return values is None
this
indicates a NULL value.
§Safety
It is the callers responsibility that the idx < self.len()
.
Sourcepub unsafe fn value_unchecked(&self, idx: usize) -> T::Physical<'_>
pub unsafe fn value_unchecked(&self, idx: usize) -> T::Physical<'_>
Get a single value from this ChunkedArray
. Null values are ignored and the returned
value could be garbage if it was masked out by NULL. Note that the value always is initialized.
§Safety
It is the callers responsibility that the idx < self.len()
.
pub fn first(&self) -> Option<T::Physical<'_>>
pub fn last(&self) -> Option<T::Physical<'_>>
pub fn get_as_series(&self, idx: usize) -> Option<Series>
pub fn get_as_series(&self, idx: usize) -> Option<Series>
dtype-array
only.pub fn layout(&self) -> ChunkedArrayLayout<'_, T>
Sourcepub fn cont_slice(&self) -> PolarsResult<&[T::Native]>
pub fn cont_slice(&self) -> PolarsResult<&[T::Native]>
Returns the values of the array as a contiguous slice.
Sourcepub fn data_views(&self) -> impl DoubleEndedIterator<Item = &[T::Native]>
pub fn data_views(&self) -> impl DoubleEndedIterator<Item = &[T::Native]>
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 '_ + Send + Sync + ExactSizeIterator<Item = T::Native> + DoubleEndedIterator + TrustedLen
Sourcepub unsafe fn group_tuples_perfect(
&self,
num_groups: usize,
multithreaded: bool,
group_capacity: usize,
) -> GroupsType
Available on crate feature algorithm_group_by
only.
pub unsafe fn group_tuples_perfect( &self, num_groups: usize, multithreaded: bool, group_capacity: usize, ) -> GroupsType
algorithm_group_by
only.Use the indexes as perfect groups.
§Safety
This ChunkedArray must contain each value in [0..num_groups) at least once, and nothing outside this range.
Trait Implementations§
Source§impl<K: PolarsDataType, T: PolarsDataType> Clone for Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Clone for Logical<K, T>
Source§impl<K: PolarsDataType, T: PolarsDataType> Default for Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Default for Logical<K, T>
Source§impl<K: PolarsDataType, T: PolarsDataType> Deref for Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Deref for Logical<K, T>
Source§impl<K: PolarsDataType, T: PolarsDataType> DerefMut for Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> DerefMut for Logical<K, T>
Auto Trait Implementations§
impl<Logical, Physical> !Freeze for Logical<Logical, Physical>
impl<Logical, Physical> !RefUnwindSafe for Logical<Logical, Physical>
impl<Logical, Physical> Send for Logical<Logical, Physical>
impl<Logical, Physical> Sync for Logical<Logical, Physical>
impl<Logical, Physical> Unpin for Logical<Logical, Physical>
impl<Logical, Physical> !UnwindSafe for Logical<Logical, Physical>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoColumn for Twhere
T: IntoSeries,
impl<T> IntoColumn for Twhere
T: IntoSeries,
fn into_column(self) -> Column
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more