Polars DataType class (polars_dtype)
Description
Polars supports a variety of data types that fall broadly under the
following categories:
-
Numeric data types: signed integers, unsigned integers, floating point
numbers, and decimals.
-
Nested data types: lists, structs, and arrays.
-
Temporal: dates, datetimes, times, and time deltas.
-
Miscellaneous: strings, binary data, Booleans, categoricals, and enums.
All types support missing values represented by the special value
null. This is not to be conflated with the special value
NaN in floating number data types; see the section about
floating point numbers for more information.
Usage
pl__Decimal(precision = 38L, scale = 0L)
pl__Datetime(time_unit = c("us", "ns", "ms"), time_zone = NULL)
pl__Duration(time_unit = c("us", "ns", "ms"))
pl__Categorical(ordering = deprecated())
pl__Enum(categories)
pl__Array(inner, shape)
pl__List(inner)
pl__Struct(...)
Arguments
precision
|
Single integer should be in the range 1 to 38.
The maximum number of digits in each number.
|
scale
|
Single integer. Number of digits to the right of the decimal point in
each number. The default is 0.
|
time_unit
|
One of “us” (default, microseconds), “ns”
(nanoseconds) or “ms”(milliseconds). Representing the unit
of time.
|
time_zone
|
A string or NULL (default). Representing the timezone.
|
ordering
|
One of “lexical” or “physical”. This argument
is deprecated and ignored. Always behaves as if “lexical”
was passed.
|
categories
|
A character vector. Should not contain NA values and all
values should be unique.
|
inner
|
A polars data type object.
|
shape
|
A integer-ish vector, representing the shape of the Array.
|
…
|
\<dynamic-dots\> Name-value pairs of polars data type. Each
pair represents a field of the Struct.
|
Details
Full data types table
|
Type(s)
|
Details
|
Boolean
|
Boolean type that is bit packed efficiently.
|
Int8, Int16, Int32,
Int64
|
Varying-precision signed integer types.
|
UInt8, UInt16, UInt32,
UInt64
|
Varying-precision unsigned integer types.
|
Float32, Float64
|
Varying-precision signed floating point numbers.
|
Decimal
|
Decimal 128-bit type with optional precision and non-negative scale.
|
String
|
Variable length UTF-8 encoded string data, typically Human-readable.
|
Binary
|
Stores arbitrary, varying length raw binary data.
|
Date
|
Represents a calendar date.
|
Time
|
Represents a time of day.
|
Datetime
|
Represents a calendar date and time of day.
|
Duration
|
Represents a time duration.
|
Array
|
Arrays with a known, fixed shape per series; akin to numpy arrays.
|
List
|
Homogeneous 1D container with variable length.
|
Categorical
|
Efficient encoding of string data where the categories are inferred at
runtime.
|
Enum
|
Efficient ordered encoding of a set of predetermined string categories.
|
Struct
|
Composite product type that can store multiple fields.
|
Null
|
Represents null values.
|
Examples
library("polars")
pl$Int8
#> Decimal(precision=38, scale=2)
#> Datetime(time_unit='us', time_zone=NULL)
#> Duration(time_unit='us')
pl$Array(pl$Int32, c(2, 3))
#> Array(Int32, shape=c(2, 3))
#> Categorical(ordering='lexical')
pl$Enum(c("a", "b", "c"))
#> Enum(categories=c('a', 'b', 'c'))
pl$Struct(a = pl$Int32, b = pl$String)
#> Struct(`a`=Int32, `b`=String)