pub struct Logical<Logical: PolarsDataType, Physical: PolarsDataType> {
pub phys: ChunkedArray<Physical>,
pub dtype: DataType,
/* private fields */
}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.
Fields§
§phys: ChunkedArray<Physical>§dtype: DataTypeImplementations§
Source§impl<T: PolarsCategoricalType> Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>
impl<T: PolarsCategoricalType> Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>
pub fn sort_with(&self, options: SortOptions) -> CategoricalChunked<T>
dtype-categorical only.Sourcepub fn sort(&self, descending: bool) -> CategoricalChunked<T>
Available on crate feature dtype-categorical only.
pub fn sort(&self, descending: bool) -> CategoricalChunked<T>
dtype-categorical only.Returned a sorted ChunkedArray.
Sourcepub fn arg_sort(&self, options: SortOptions) -> IdxCa
Available on crate feature dtype-categorical only.
pub fn arg_sort(&self, options: SortOptions) -> IdxCa
dtype-categorical only.Retrieve the indexes needed to sort this array.
Source§impl<T: PolarsCategoricalType> Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>
impl<T: PolarsCategoricalType> Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>
pub fn is_enum(&self) -> bool
dtype-categorical only.Sourcepub fn uses_lexical_ordering(&self) -> bool
Available on crate feature dtype-categorical only.
pub fn uses_lexical_ordering(&self) -> bool
dtype-categorical only.Return whether or not the CategoricalChunked uses the lexical order
of the string values when sorting.
pub fn full_null_with_dtype( name: PlSmallStr, length: usize, dtype: DataType, ) -> Self
dtype-categorical only.Sourcepub fn from_cats_and_dtype(
cat_ids: ChunkedArray<T::PolarsPhysical>,
dtype: DataType,
) -> Self
Available on crate feature dtype-categorical only.
pub fn from_cats_and_dtype( cat_ids: ChunkedArray<T::PolarsPhysical>, dtype: DataType, ) -> Self
dtype-categorical only.Create a CategoricalChunked from a physical array and dtype.
Checks that all the category ids are valid, mapping invalid ones to nulls.
Sourcepub unsafe fn from_cats_and_dtype_unchecked(
cat_ids: ChunkedArray<T::PolarsPhysical>,
dtype: DataType,
) -> Self
Available on crate feature dtype-categorical only.
pub unsafe fn from_cats_and_dtype_unchecked( cat_ids: ChunkedArray<T::PolarsPhysical>, dtype: DataType, ) -> Self
dtype-categorical only.Create a CategoricalChunked from a physical array and dtype.
§Safety
It’s not checked that the indices are in-bounds or that the dtype is correct.
Sourcepub fn get_mapping(&self) -> &Arc<CategoricalMapping>
Available on crate feature dtype-categorical only.
pub fn get_mapping(&self) -> &Arc<CategoricalMapping>
dtype-categorical only.Get a reference to the mapping of categorical types to the string values.
Sourcepub fn iter_str(&self) -> impl PolarsIterator<Item = Option<&str>>
Available on crate feature dtype-categorical only.
pub fn iter_str(&self) -> impl PolarsIterator<Item = Option<&str>>
dtype-categorical only.Create an Iterator that iterates over the &str values of the CategoricalChunked.
Sourcepub fn from_str_iter<'a, I: IntoIterator<Item = Option<&'a str>>>(
name: PlSmallStr,
dtype: DataType,
strings: I,
) -> PolarsResult<Self>
Available on crate feature dtype-categorical only.
pub fn from_str_iter<'a, I: IntoIterator<Item = Option<&'a str>>>( name: PlSmallStr, dtype: DataType, strings: I, ) -> PolarsResult<Self>
dtype-categorical only.Converts from strings to this CategoricalChunked.
If this dtype is an Enum any non-existing strings get mapped to null.
pub fn to_arrow(&self, compat_level: CompatLevel) -> DictionaryArray<T::Native>
dtype-categorical only.Source§impl Logical<DecimalType, Int128Type>
impl Logical<DecimalType, Int128Type>
pub fn precision(&self) -> usize
dtype-decimal only.pub fn scale(&self) -> usize
dtype-decimal only.pub fn with_prec_scale( &self, prec: usize, scale: usize, strict: bool, ) -> PolarsResult<Cow<'_, Self>>
dtype-decimal only.Sourcepub fn into_phys_with_prec_scale_or_sentinel(
&self,
prec: usize,
scale: usize,
sentinel: i128,
) -> Int128Chunked
Available on crate feature dtype-decimal only.
pub fn into_phys_with_prec_scale_or_sentinel( &self, prec: usize, scale: usize, sentinel: i128, ) -> Int128Chunked
dtype-decimal only.Converts self to a physical representation with the given precision and scale, returning the given sentinel value instead for values which don’t fit in the given precision and scale. This can be useful for comparisons.
Source§impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>
Sourcepub unsafe fn new_logical(
phys: ChunkedArray<T>,
dtype: DataType,
) -> Logical<K, T>
pub unsafe fn new_logical( phys: ChunkedArray<T>, dtype: DataType, ) -> Logical<K, T>
§Safety
You must uphold the logical types’ invariants.
Source§impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>where
Self: LogicalType,
impl<K: PolarsDataType, T: PolarsDataType> Logical<K, T>where
Self: LogicalType,
pub fn name(&self) -> &PlSmallStr
pub fn rename(&mut self, name: PlSmallStr)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn null_count(&self) -> usize
pub fn has_nulls(&self) -> bool
pub fn is_null(&self) -> BooleanChunked
pub fn is_not_null(&self) -> BooleanChunked
pub fn split_at(&self, offset: i64) -> (Self, Self)
pub fn slice(&self, offset: i64, length: usize) -> Self
pub fn field(&self) -> Field
pub fn physical(&self) -> &ChunkedArray<T>
pub fn physical_mut(&mut self) -> &mut ChunkedArray<T>
pub fn into_physical(self) -> ChunkedArray<T>
Trait Implementations§
Source§impl<T: PolarsCategoricalType> ChunkCompareEq<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>> for CategoricalChunked<T>where
ChunkedArray<T::PolarsPhysical>: for<'a> ChunkCompareEq<&'a ChunkedArray<T::PolarsPhysical>, Item = BooleanChunked>,
Available on crate feature dtype-categorical only.
impl<T: PolarsCategoricalType> ChunkCompareEq<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>> for CategoricalChunked<T>where
ChunkedArray<T::PolarsPhysical>: for<'a> ChunkCompareEq<&'a ChunkedArray<T::PolarsPhysical>, Item = BooleanChunked>,
dtype-categorical only.type Item = Result<ChunkedArray<BooleanType>, PolarsError>
Source§fn equal_missing(&self, rhs: &Self) -> Self::Item
fn equal_missing(&self, rhs: &Self) -> Self::Item
None == None.Source§fn not_equal_missing(&self, rhs: &Self) -> Self::Item
fn not_equal_missing(&self, rhs: &Self) -> Self::Item
None == None.Source§impl<T: PolarsCategoricalType> ChunkCompareIneq<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>> for CategoricalChunked<T>where
ChunkedArray<T::PolarsPhysical>: for<'a> ChunkCompareIneq<&'a ChunkedArray<T::PolarsPhysical>, Item = BooleanChunked>,
Available on crate feature dtype-categorical only.
impl<T: PolarsCategoricalType> ChunkCompareIneq<&Logical<T, <T as PolarsCategoricalType>::PolarsPhysical>> for CategoricalChunked<T>where
ChunkedArray<T::PolarsPhysical>: for<'a> ChunkCompareIneq<&'a ChunkedArray<T::PolarsPhysical>, Item = BooleanChunked>,
dtype-categorical only.type Item = Result<ChunkedArray<BooleanType>, PolarsError>
Source§fn gt(&self, rhs: &CategoricalChunked<T>) -> Self::Item
fn gt(&self, rhs: &CategoricalChunked<T>) -> Self::Item
Source§fn gt_eq(&self, rhs: &CategoricalChunked<T>) -> Self::Item
fn gt_eq(&self, rhs: &CategoricalChunked<T>) -> Self::Item
Source§fn lt(&self, rhs: &CategoricalChunked<T>) -> Self::Item
fn lt(&self, rhs: &CategoricalChunked<T>) -> Self::Item
Source§fn lt_eq(&self, rhs: &CategoricalChunked<T>) -> Self::Item
fn lt_eq(&self, rhs: &CategoricalChunked<T>) -> Self::Item
Source§impl<K: PolarsDataType, T: PolarsDataType> Clone for Logical<K, T>
impl<K: PolarsDataType, T: PolarsDataType> Clone 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