polars.datatypes.Map#
- class polars.datatypes.Map(key: PolarsDataType | PythonDataType, value: PolarsDataType | PythonDataType)[source]#
Key-value mapping type.
Keys are unique within a row and never null. Entry order is preserved and participates in equality and hashing.
Duplicate keys are resolved when a map is built, keeping the first position and the last value.
- Parameters:
- key
The
DataTypeof the keys. Must be row-encodable, soObjectis not allowed.A nested key dtype is accepted by Polars but has no Python representation.
- value
The
DataTypeof the values.
Examples
>>> s = pl.Series("a", [{"x": 1, "y": 2}], dtype=pl.Map(pl.String, pl.Int64)) >>> s shape: (1,) Series: 'a' [map[str, i64]] [ {"x": 1, "y": 2} ]
- __init__(
- key: PolarsDataType | PythonDataType,
- value: PolarsDataType | PythonDataType,
Methods
__init__(key, value)base_type()Return this DataType's fundamental/root type class.
from_python(py_type)Return the Polars data type corresponding to a given Python type.
is_(other)Check if this DataType is the same as another DataType.
is_decimal()Check whether the data type is a decimal type.
is_extension()Check whether the data type is an extension type.
is_float()Check whether the data type is a floating point type.
is_integer()Check whether the data type is an integer type.
is_nested()Check whether the data type is a nested type.
is_numeric()Check whether the data type is a numeric type.
is_object()Check whether the data type is an object type.
is_signed_integer()Check whether the data type is a signed integer type.
is_temporal()Check whether the data type is a temporal type.
is_unsigned_integer()Check whether the data type is an unsigned integer type.
to_dtype_expr()Return a
DataTypeExprwith a staticDataType.to_python()Return the Python type corresponding to this Polars data type.
Attributes
keyvalue