pub enum DataType {
Show 27 variants
Boolean,
UInt8,
UInt16,
UInt32,
UInt64,
Int8,
Int16,
Int32,
Int64,
Int128,
Float32,
Float64,
Decimal(Option<usize>, Option<usize>),
String,
Binary,
BinaryOffset,
Date,
Datetime(TimeUnit, Option<TimeZone>),
Duration(TimeUnit),
Time,
Array(Box<DataType>, usize),
List(Box<DataType>),
Object(&'static str),
Null,
Categorical(Arc<Categories>, Arc<CategoricalMapping>),
Enum(Arc<FrozenCategories>, Arc<CategoricalMapping>),
Unknown(UnknownKind),
}Variants§
Boolean
UInt8
UInt16
UInt32
UInt64
Int8
Int16
Int32
Int64
Int128
Float32
Float64
Decimal(Option<usize>, Option<usize>)
dtype-decimal only.Fixed point decimal type optional precision and non-negative scale. This is backed by a signed 128-bit integer which allows for up to 38 significant digits. Meaning max precision is 38.
String
String data
Binary
BinaryOffset
Date
A 32-bit date representing the elapsed time since UNIX epoch (1970-01-01) in days (32 bits).
Datetime(TimeUnit, Option<TimeZone>)
A 64-bit date representing the elapsed time since UNIX epoch (1970-01-01) in the given timeunit (64 bits).
Duration(TimeUnit)
64-bit integer representing difference between times in milliseconds or nanoseconds
Time
A 64-bit time representing the elapsed time since midnight in nanoseconds
Array(Box<DataType>, usize)
dtype-array only.A nested list with a fixed size in each row
List(Box<DataType>)
A nested list with a variable size in each row
Object(&'static str)
object only.A generic type that can be used in a Series
&’static str can be used to determine/set inner type
Null
Categorical(Arc<Categories>, Arc<CategoricalMapping>)
dtype-categorical only.Enum(Arc<FrozenCategories>, Arc<CategoricalMapping>)
dtype-categorical only.Unknown(UnknownKind)
Implementations§
Source§impl DataType
impl DataType
pub const IDX_DTYPE: Self = { { DataType::UInt32 } }
pub fn value_within_range(&self, other: AnyValue<'_>) -> bool
Sourcepub fn materialize_unknown(self, allow_unknown: bool) -> PolarsResult<DataType>
pub fn materialize_unknown(self, allow_unknown: bool) -> PolarsResult<DataType>
Materialize this datatype if it is unknown. All other datatypes are left unchanged.
Sourcepub fn get_shape(&self) -> Option<Vec<usize>>
Available on crate feature dtype-array only.
pub fn get_shape(&self) -> Option<Vec<usize>>
dtype-array only.Get the full shape of a multidimensional array.
Sourcepub fn inner_dtype(&self) -> Option<&DataType>
pub fn inner_dtype(&self) -> Option<&DataType>
Get the inner data type of a nested type.
Sourcepub fn into_inner_dtype(self) -> Option<DataType>
pub fn into_inner_dtype(self) -> Option<DataType>
Get the inner data type of a nested type.
Sourcepub fn try_into_inner_dtype(self) -> PolarsResult<DataType>
pub fn try_into_inner_dtype(self) -> PolarsResult<DataType>
Get the inner data type of a nested type.
Sourcepub fn leaf_dtype(&self) -> &DataType
pub fn leaf_dtype(&self) -> &DataType
Get the absolute inner data type of a nested type.
Sourcepub fn array_leaf_dtype(&self) -> Option<&DataType>
Available on crate feature dtype-array only.
pub fn array_leaf_dtype(&self) -> Option<&DataType>
dtype-array only.Get the inner data type of a multidimensional array.
Sourcepub fn cast_leaf(&self, to: DataType) -> DataType
pub fn cast_leaf(&self, to: DataType) -> DataType
Cast the leaf types of Lists/Arrays and keep the nesting.
Sourcepub fn can_cast_to(&self, to: &DataType) -> Option<bool>
pub fn can_cast_to(&self, to: &DataType) -> Option<bool>
Return whether the cast to to makes sense.
If it None, we are not sure.
pub fn implode(self) -> DataType
Sourcepub fn to_physical(&self) -> DataType
pub fn to_physical(&self) -> DataType
Convert to the physical data type
pub fn is_supported_list_arithmetic_input(&self) -> bool
Sourcepub fn is_logical(&self) -> bool
pub fn is_logical(&self) -> bool
Check if this DataType is a logical type
Sourcepub fn is_temporal(&self) -> bool
pub fn is_temporal(&self) -> bool
Check if this DataType is a temporal type
Sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Check if datatype is a primitive type. By that we mean that it is not a nested or logical type.
Sourcepub fn is_primitive_numeric(&self) -> bool
pub fn is_primitive_numeric(&self) -> bool
Check if this DataType is a primitive numeric type (excludes Decimal).
pub fn is_nested(&self) -> bool
pub fn is_binary(&self) -> bool
pub fn is_date(&self) -> bool
pub fn is_datetime(&self) -> bool
pub fn is_duration(&self) -> bool
pub fn is_object(&self) -> bool
pub fn is_null(&self) -> bool
pub fn contains_views(&self) -> bool
pub fn contains_categoricals(&self) -> bool
pub fn contains_objects(&self) -> bool
pub fn contains_list_recursive(&self) -> bool
pub fn contains_unknown(&self) -> bool
Sourcepub fn is_decimal(&self) -> bool
pub fn is_decimal(&self) -> bool
Check if this DataType is a Decimal type (of any scale/precision).
Sourcepub fn is_float(&self) -> bool
pub fn is_float(&self) -> bool
Check if this DataType is a basic floating point type (excludes Decimal).
Note, this also includes Unknown(UnknownKind::Float).
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Check if this DataType is an integer. Note, this also includes Unknown(UnknownKind::Int).
pub fn is_signed_integer(&self) -> bool
pub fn is_unsigned_integer(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_categorical(&self) -> bool
pub fn is_enum(&self) -> bool
Sourcepub fn to_arrow_field(
&self,
name: PlSmallStr,
compat_level: CompatLevel,
) -> ArrowField
pub fn to_arrow_field( &self, name: PlSmallStr, compat_level: CompatLevel, ) -> ArrowField
Convert to an Arrow Field.
Sourcepub fn max(&self) -> PolarsResult<Scalar>
pub fn max(&self) -> PolarsResult<Scalar>
Try to get the maximum value for this datatype.
Sourcepub fn min(&self) -> PolarsResult<Scalar>
pub fn min(&self) -> PolarsResult<Scalar>
Try to get the minimum value for this datatype.
Sourcepub fn to_arrow(&self, compat_level: CompatLevel) -> ArrowDataType
pub fn to_arrow(&self, compat_level: CompatLevel) -> ArrowDataType
Convert to an Arrow data type.
pub fn try_to_arrow( &self, compat_level: CompatLevel, ) -> PolarsResult<ArrowDataType>
pub fn is_nested_null(&self) -> bool
Sourcepub fn matches_schema_type(&self, schema_type: &DataType) -> PolarsResult<bool>
pub fn matches_schema_type(&self, schema_type: &DataType) -> PolarsResult<bool>
Answers if this type matches the given type of a schema.
Allows (nested) Null types in this type to match any type in the schema, but not vice versa. In such a case Ok(true) is returned, because a cast is necessary. If no cast is necessary Ok(false) is returned, and an error is returned if the types are incompatible.
pub fn is_unknown(&self) -> bool
pub fn nesting_level(&self) -> usize
Sourcepub fn cat_physical(&self) -> PolarsResult<CategoricalPhysical>
Available on crate feature dtype-categorical only.
pub fn cat_physical(&self) -> PolarsResult<CategoricalPhysical>
dtype-categorical only.If this dtype is a Categorical or Enum, returns the physical backing type.
Sourcepub fn cat_mapping(&self) -> PolarsResult<&Arc<CategoricalMapping>>
Available on crate feature dtype-categorical only.
pub fn cat_mapping(&self) -> PolarsResult<&Arc<CategoricalMapping>>
dtype-categorical only.If this dtype is a Categorical or Enum, returns the underlying mapping.
pub fn from_categories(cats: Arc<Categories>) -> Self
dtype-categorical only.pub fn from_frozen_categories(fcats: Arc<FrozenCategories>) -> Self
dtype-categorical only.pub fn is_numeric(&self) -> bool
Source§impl DataType
impl DataType
pub fn boxed(self) -> Box<DataType>
pub fn from_arrow_field(field: &ArrowField) -> DataType
pub fn from_arrow_dtype(dt: &ArrowDataType) -> DataType
pub fn from_arrow(dt: &ArrowDataType, md: Option<&Metadata>) -> DataType
Trait Implementations§
Source§impl<'a> Deserialize<'a> for DataType
Available on crate feature serde only.
impl<'a> Deserialize<'a> for DataType
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
impl Eq for DataType
Auto Trait Implementations§
impl Freeze for DataType
impl RefUnwindSafe for DataType
impl Send for DataType
impl Sync for DataType
impl Unpin for DataType
impl UnwindSafe for DataType
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more