Search code examples
pythonpython-polars

Where can I find datatypes to which I can cast in polars?


Where can I find datatypes to which I can cast in polars?

This is the second time I am searching for this and I cannot find the right reference for them. There are types in the User's Guide, but it is not mentioned how to call those types. Also there is no mentioning of the data types in the Python Documentation.


Solution

  • Update: There is now a dedicated section in the User guide.


    All the types you read in the user guide are available under the polars namespace. So:

    import polars as pl
    
    # available data types
    pl.Int8
    pl.Int16
    pl.Int32
    pl.Int64
    pl.UInt8
    pl.UInt16
    pl.UInt32
    pl.UInt64
    pl.Float32
    pl.Float64
    pl.Boolean
    pl.String
    pl.List
    pl.Date
    pl.Datetime
    pl.Duration
    pl.Time
    pl.Struct
    pl.Object