Skip to content

Polars Types

Code

import polars as pl

Enum

Create

Action Code Details
Define enum
pl.Enum(['a', 'b', 'c'])
Create enum from Literal
from typing import Literal
Labels = Literal['a', 'b', 'c']
pl.Enum(Labels.__args__)

Extract

Action Code Details
Get the enum categories
x.categories

List

Variable-length list elements

Create

Action Code Details
List with undefined inner elements type
pl.List
List of booleans
pl.list(bool)
List of integers
pl.list(int)
List of floats
pl.list(float)
List of strings
pl.list(str)

Test

Action Code Details
Test if type is list of numeric elements
x.inner.is_numeric()

Extract

Action Code Details
Get inner elements type
x.inner