Skip to content

DataType ​

Namespace: Polars.FSharp

Polars data types for casting and schema definitions.

Properties & Indexers ​

PropertyTypeDescription
ArrayShapeuint32[]Gets the dimensional shape of the Array.
ArrayWidthuint32Gets the first-dimension fixed width (number of elements in the leading dimension) of the Array.
BinaryDataType-
BooleanDataType-
CategoriesCategoriesThe categories of this DataType, if it is a Categorical type.
Codeint-
DateDataType-
EnumCategoriesFrozenCategoriesThe frozen categories of this DataType, if it is an Enum type.
Float16DataType-
Float32DataType-
Float64DataType-
InnerTypeDataTypeGets the immediate inner element DataType of an Array or a List.
Int128DataType-
Int16DataType-
Int32DataType-
Int64DataType-
Int8DataType-
IsCategoricalbool-
IsDecimalbool-
IsEnumbool-
IsExtensionbool-
IsFloatbool-
IsIntegerbool-
IsNestedbool-
IsNumericbool-
IsSignedIntegerbool-
IsTemporalbool-
IsUnsignedIntegerbool-
KindDataTypeKind-
LeafTypeDataTypeRecursively unwraps all outer Array and List layers to retrieve the leaf (primitive/base) DataType. Returns itself if this DataType is not nested.
NullDataType-
PrecisionintGets the decimal precision. Throws InvalidOperationException if the data type is not Decimal.
SameAsInputDataType-
ScaleintGets the decimal scale. Throws InvalidOperationException if the data type is not Decimal.
StringDataType-
TimeDataType-
TimeUnitTimeUnit-
TimeZonestring option-
TimeZoneInfoTimeZoneInfo option-
UInt128DataType-
UInt16DataType-
UInt32DataType-
UInt64DataType-
UInt8DataType-
UnknownDataType-

Constructors & Static Methods ​

new ​

fsharp
new(handle: DataTypeHandle, kind: DataTypeKind) : DataType

Parameters

NameTypeDescription
handleDataTypeHandle-
kindDataTypeKind-

Array ​

fsharp
static member Array(inner: DataType, shape: uint32[]) : DataType

Parameters

NameTypeDescription
innerDataType-
shapeuint32[]-

Categorical ​

fsharp
static member Categorical(?categories: Categories) : DataType

Parameters

NameTypeDescription
categoriesCategories (optional)-

Datetime ​

fsharp
static member Datetime(unit: TimeUnit, ?tz: string) : DataType

Parameters

NameTypeDescription
unitTimeUnit-
tzstring (optional)-

Decimal ​

fsharp
static member Decimal(?precision: int, ?scale: int) : DataType

Parameters

NameTypeDescription
precisionint (optional)-
scaleint (optional)-

Duration ​

fsharp
static member Duration(unit: TimeUnit) : DataType

Parameters

NameTypeDescription
unitTimeUnit-

Enum ​

fsharp
static member Enum(frozen: FrozenCategories) : DataType

Parameters

NameTypeDescription
frozenFrozenCategories-

Extension ​

fsharp
static member Extension(name: string, storage: DataType, ?metadata: string) : DataType

Parameters

NameTypeDescription
namestring-
storageDataType-
metadatastring (optional)-

FromArrowType ​

fsharp
static member FromArrowType(arrowType: IArrowType) : DataType

Parameters

NameTypeDescription
arrowTypeIArrowType-

FromHandle ​

fsharp
static member FromHandle(handle: DataTypeHandle) : DataType

Parameters

NameTypeDescription
handleDataTypeHandle-

FromNetType ​

fsharp
static member FromNetType : unit -> DataType
static member FromNetType(t: Type) : DataType

Parameters

NameTypeDescription
tType-

List ​

fsharp
static member List(inner: DataType) : DataType

Parameters

NameTypeDescription
innerDataType-

Struct ​

fsharp
static member Struct(fields: seq<Field>) : DataType

Parameters

NameTypeDescription
fieldsseq<Field>-

Operators ​

op_Equality ​

fsharp
static member op_Equality(left: DataType, right: DataType) : bool

Parameters

NameTypeDescription
leftDataType-
rightDataType-

op_Implicit ​

fsharp
static member op_Implicit(t: Type) : DataType

Parameters

NameTypeDescription
tType-

op_Inequality ​

fsharp
static member op_Inequality(left: DataType, right: DataType) : bool

Parameters

NameTypeDescription
leftDataType-
rightDataType-

Instance Methods ​

GetArrowType ​

fsharp
member GetArrowType : unit -> IArrowType

GetNetType ​

fsharp
member GetNetType : unit -> Type

ToDataTypeExpr ​

Convert this DataType to a DataTypeExpr literal. Equivalent to Python's polars.DataType.to_dtype_expr()

fsharp
member ToDataTypeExpr : unit -> DataTypeExpr

ToPlDataType ​

Get the corresponding PlDataType enum value.

fsharp
member ToPlDataType : unit -> PlDataType

TryGetArrayInfo ​

Safely attempts to extract Array metadata without throwing exceptions.

fsharp
member TryGetArrayInfo : unit -> (DataType * uint32[]) option

Returns: Some(inner, shape) if this is an Array; otherwise None.


TryGetCategories ​

fsharp
member TryGetCategories : unit -> Categories option

TryGetDecimalInfo ​

Attempts to extract Decimal metadata safely.

fsharp
member TryGetDecimalInfo : unit -> (int * int) option

TryGetEnumCategories ​

fsharp
member TryGetEnumCategories : unit -> FrozenCategories option

TryGetInnerType ​

Safely attempts to extract the inner element DataType without throwing an exception.

fsharp
member TryGetInnerType : unit -> DataType option

Returns: Some(inner) if the type is an Array or List; otherwise None.


Released under the MIT License. Powered by the Polars Rust core & Apache Arrow.