Skip to main content

DataType

Enum DataType 

Source
pub enum DataType {
Show 31 variants Boolean, UInt8, UInt16, UInt32, UInt64, UInt128, Int8, Int16, Int32, Int64, Int128, Float16, Float32, Float64, Decimal(usize, 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>), Struct(Vec<Field>), Map(Box<DataType>, Box<DataType>), Unknown(UnknownKind),
}

Variants§

§

Boolean

§

UInt8

§

UInt16

§

UInt32

§

UInt64

§

UInt128

§

Int8

§

Int16

§

Int32

§

Int64

§

Int128

§

Float16

§

Float32

§

Float64

§

Decimal(usize, usize)

Available on crate feature 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)

Available on crate feature 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)

Available on crate feature 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>)

Available on crate feature dtype-categorical only.
§

Enum(Arc<FrozenCategories>, Arc<CategoricalMapping>)

Available on crate feature dtype-categorical only.
§

Struct(Vec<Field>)

Available on crate feature dtype-struct only.
§

Map(Box<DataType>, Box<DataType>)

Available on crate feature dtype-map only.

A map from keys to values, keys are unique and non-null.

§

Unknown(UnknownKind)

Implementations§

Source§

impl DataType

Source

pub const IDX_DTYPE: DataType = { { DataType::UInt32 } }

Source

pub fn pretty_format(&self) -> String

Source

pub fn value_within_range(&self, other: AnyValue<'_>) -> bool

Source

pub fn _month_days_ns_struct_type() -> DataType

Available on crate feature dtype-struct only.

Struct representation of the arrow month_day_nano_interval type.

Source

pub fn is_known(&self) -> bool

Check if the whole dtype is known.

Source

pub fn materialize_unknown( self, allow_unknown: bool, ) -> Result<DataType, PolarsError>

Materialize this datatype if it is unknown. All other datatypes are left unchanged.

Source

pub fn get_shape(&self) -> Option<Vec<usize>>

Available on crate feature dtype-array only.

Get the full shape of a multidimensional array.

Source

pub fn inner_dtype(&self) -> Option<&DataType>

Get the inner data type of a nested type.

Source

pub fn into_inner_dtype(self) -> Option<DataType>

Get the inner data type of a nested type.

Source

pub fn try_into_inner_dtype(self) -> Result<DataType, PolarsError>

Get the inner data type of a nested type.

Source

pub fn leaf_dtype(&self) -> &DataType

Get the absolute inner data type of a nested type.

Source

pub fn array_leaf_dtype(&self) -> Option<&DataType>

Available on crate feature dtype-array only.

Get the inner data type of a multidimensional array.

Source

pub fn cast_leaf(&self, to: DataType) -> DataType

Cast the leaf types of Lists/Arrays and keep the nesting.

Source

pub fn map_leaves<F>(self, f: &mut F) -> DataType
where F: FnMut(DataType) -> DataType,

Map all leaf types of nested dtypes (list, array, struct) using the supplied function.

Source

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.

Source

pub fn implode(self) -> DataType

Source

pub fn to_physical(&self) -> DataType

Convert to the physical data type

Source

pub fn byte_width(&self) -> Option<f64>

Bytes one value of this type takes, or None when that depends on the value.

Source

pub fn to_storage(&self) -> DataType

Source

pub fn is_supported_list_arithmetic_input(&self) -> bool

Source

pub fn is_supported_array_dot_input(&self) -> bool

Whether arr.dot has a kernel for this inner dtype.

Source

pub fn is_logical(&self) -> bool

Check if this DataType is a logical type

Source

pub fn is_temporal(&self) -> bool

Check if this DataType is a temporal type

Source

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.

Source

pub fn is_primitive_numeric(&self) -> bool

Check if this DataType is a primitive numeric type (excludes Decimal).

Source

pub fn is_bool(&self) -> bool

Check if this DataType is a boolean.

Source

pub fn is_list(&self) -> bool

Check if this DataType is a list.

Source

pub fn is_array(&self) -> bool

Check if this DataType is an array.

Source

pub fn is_nested(&self) -> bool

Source

pub fn is_struct(&self) -> bool

Check if this DataType is a struct

Source

pub fn is_map(&self) -> bool

Check if this DataType is a map

Source

pub fn is_binary(&self) -> bool

Source

pub fn is_date(&self) -> bool

Source

pub fn is_datetime(&self) -> bool

Source

pub fn is_duration(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn contains_views(&self) -> bool

Source

pub fn contains_categoricals(&self) -> bool

Source

pub fn contains_enums(&self) -> bool

Source

pub fn contains_objects(&self) -> bool

Source

pub fn contains_map(&self) -> bool

Source

pub fn contains_list_recursive(&self) -> bool

Source

pub fn contains_unknown(&self) -> bool

Source

pub fn contains_dtype_recursive(&self, dtype: &DataType) -> bool

Source

pub fn is_ord(&self) -> bool

Check if type is sortable

Source

pub fn is_decimal(&self) -> bool

Check if this DataType is a Decimal type (of any scale/precision).

Source

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).

Source

pub fn is_integer(&self) -> bool

Check if this DataType is an integer. Note, this also includes Unknown(UnknownKind::Int).

Source

pub fn is_signed_integer(&self) -> bool

Source

pub fn is_unsigned_integer(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_categorical(&self) -> bool

Source

pub fn is_enum(&self) -> bool

Source

pub fn as_map(&self) -> Option<(&DataType, &DataType)>

Available on crate feature dtype-map only.

Return the key and value dtypes of a Map, or None for any other dtype.

Source

pub fn map_entries_dtype(&self) -> Option<DataType>

Available on crate feature dtype-map only.

The Struct {key, value} entries dtype of this Map. Returns None for any other dtype.

Source

pub fn map_storage_dtype(&self) -> Option<DataType>

Available on crate feature dtype-map only.

Returns the dtype of the Series used internally to store this Map: List(Struct {key, value}). Returns None for any other dtype.

This is intentionally separate from DataType::to_storage. Adding Map there would imply also unwrapping it in Series::to_storage. Python map_elements calls the latter, so each map row would reach the UDF as a List(Struct) value instead of a dict.

Source

pub fn map_from_named_entries_dtype(&self) -> Result<DataType, PolarsError>

Available on crate feature dtype-map only.

The Map dtype whose entries are self, matching the key and value fields by name.

Source

pub fn is_valid_map_key(&self) -> bool

Available on crate feature dtype-map only.

Whether this dtype may be used as the key dtype of a Map.

Source

pub fn ensure_valid_map_key(&self) -> Result<(), PolarsError>

Available on crate feature dtype-map only.
Source

pub fn is_valid_map_value(&self) -> bool

Available on crate feature dtype-map only.

Whether this dtype may be used as the value dtype of a Map.

Source

pub fn ensure_valid_map_value(&self) -> Result<(), PolarsError>

Available on crate feature dtype-map only.
Source

pub fn ensure_valid_map_dtype(&self) -> Result<(), PolarsError>

Available on crate feature dtype-map only.

Validate the key and value dtypes of a Map. Errors for any other dtype.

Source

pub fn ensure_valid_map_dtypes(&self) -> Result<(), PolarsError>

Available on crate feature dtype-map only.

Validate every Map nested in this dtype. Unlike Self::ensure_valid_map_dtype, this accepts dtypes that are not a Map themselves.

Source

pub fn is_extension(&self) -> bool

Source

pub fn to_arrow_field( &self, name: PlSmallStr, compat_level: CompatLevel, ) -> Field

Convert to an Arrow Field.

Source

pub fn to_arrow_field_metadata( &self, ) -> Option<BTreeMap<PlSmallStr, PlSmallStr>>

Source

pub fn max(&self) -> Result<Scalar, PolarsError>

Try to get the maximum value for this datatype.

Source

pub fn min(&self) -> Result<Scalar, PolarsError>

Try to get the minimum value for this datatype.

Source

pub fn to_arrow(&self, compat_level: CompatLevel) -> ArrowDataType

Convert to an Arrow data type.

Source

pub fn try_to_arrow( &self, compat_level: CompatLevel, ) -> Result<ArrowDataType, PolarsError>

Source

pub fn is_nested_null(&self) -> bool

Source

pub fn matches_schema_type( &self, schema_type: &DataType, ) -> Result<bool, PolarsError>

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, container shapes, or Struct field names are incompatible.

Source

pub fn is_unknown(&self) -> bool

Source

pub fn nesting_level(&self) -> usize

Source

pub fn cat_physical(&self) -> Result<CategoricalPhysical, PolarsError>

Available on crate feature dtype-categorical only.

If this dtype is a Categorical or Enum, returns the physical backing type.

Source

pub fn cat_mapping(&self) -> Result<&Arc<CategoricalMapping>, PolarsError>

Available on crate feature dtype-categorical only.

If this dtype is a Categorical or Enum, returns the underlying mapping.

Source

pub fn from_categories(cats: Arc<Categories>) -> DataType

Available on crate feature dtype-categorical only.
Source

pub fn from_frozen_categories(fcats: Arc<FrozenCategories>) -> DataType

Available on crate feature dtype-categorical only.
Source

pub fn is_numeric(&self) -> bool

Source

pub fn numeric_to_unsigned_bit_repr(&self) -> Option<DataType>

Source§

impl DataType

Source

pub fn visit_with(&self, visitor_fn: impl FnMut(&DataType))

Source

pub fn try_visit_with( &self, visitor_fn: impl FnMut(&DataType) -> Result<(), PolarsError>, ) -> Result<(), PolarsError>

Source

pub fn try_mutate_with<'d>( dtype: Cow<'d, DataType>, visitor_fn: impl FnMut(Cow<'d, DataType>) -> Result<Cow<'d, DataType>, PolarsError>, ) -> Result<Cow<'d, DataType>, PolarsError>

Source§

impl DataType

Source

pub fn boxed(self) -> Box<DataType>

Source

pub fn from_arrow_field(field: &Field) -> DataType

Source

pub fn from_arrow_dtype(dt: &ArrowDataType) -> DataType

Source

pub fn arrow_value_scale(dtype: &ArrowDataType) -> i64

The factor polars multiplies the values of an Arrow dtype by to store them as Self::from_arrow_dtype: Arrow seconds become milliseconds and every time of day nanoseconds, all other values stay as they are.

Source

pub fn from_arrow( dt: &ArrowDataType, md: Option<&BTreeMap<PlSmallStr, PlSmallStr>>, ) -> DataType

Trait Implementations§

Source§

impl AsRef<DataType> for Field

Source§

fn as_ref(&self) -> &DataType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<DataType> for DataType

Source§

fn as_ref(&self) -> &DataType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> Deserialize<'a> for DataType

Source§

fn deserialize<D>( deserializer: D, ) -> Result<DataType, <D as Deserializer<'a>>::Error>
where D: Deserializer<'a>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DataType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for DataType

Source§

impl<'a> From<&AnyValue<'a>> for DataType

Source§

fn from(value: &AnyValue<'a>) -> DataType

Converts to this type from the input type.
Source§

impl From<AnyValue<'_>> for DataType

Source§

fn from(value: AnyValue<'_>) -> DataType

Converts to this type from the input type.
Source§

impl From<CategoricalPhysical> for DataType

Available on crate feature dtype-categorical only.
Source§

fn from(phys: CategoricalPhysical) -> DataType

Converts to this type from the input type.
§

impl From<DataType> for DataTypeExpr

§

fn from(value: DataType) -> DataTypeExpr

Converts to this type from the input type.
Source§

impl From<SerializableDataType> for DataType

Source§

fn from(dt: SerializableDataType) -> DataType

Converts to this type from the input type.
Source§

impl Hash for DataType

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DataType

Source§

fn eq(&self, other: &DataType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DataType

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
§

impl<T> PlanCallbackArgs for T

§

impl<T> PlanCallbackOut for T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> ToCompactString for T
where T: Display,

§

fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>

Fallible version of [ToCompactString::to_compact_string()] Read more
§

fn to_compact_string(&self) -> CompactString

Converts the given value to a [CompactString]. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more