On this page:
Polars:   Racket bindings to Polars
9.3

Polars: Racket bindings to Polars🔗ℹ

bkc

 (require polars) package: polars

polars provides Racket bindings to the Polars DataFrame library. The bindings call into a native compatibility library (libcompat) built from the Rust polars crate; prebuilt shared objects for Linux (x86-64) and macOS (arm64) ship with the package and are installed automatically, so no Rust toolchain is required at install time.

The polars module re-exports three groups of operations:

  • Series — typed, one-dimensional columns of data.

  • Expressions — composable, lazily-evaluated column expressions used to describe transformations.

  • DataFrames and LazyFrames — tabular data and the lazy query plans that produce it.

Temporal values exchanged with Racket use gregor dates and datetimes.

This manual has two parts: the User guide works through the library by example, and the Reference documents the public API.

Acknowledgements. This library and its documentation owe a great deal to the Polars project — the Rust crate the bindings call into, and the user guide and API documentation that shaped this manual — and to the Racket libraries it builds on, in particular gregor for temporal values and threading for ~>. We are grateful for all of them.

    1 User guide

      1.1 Getting started

        1.1.1 Installing

        1.1.2 Reading & writing

        1.1.3 Expressions and contexts

          1.1.3.1 select

          1.1.3.2 with-columns

          1.1.3.3 filter

          1.1.3.4 group-by

          1.1.3.5 More complex queries

        1.1.4 Combining dataframes

          1.1.4.1 Joining

          1.1.4.2 Concatenating

      1.2 Concepts

        1.2.1 Data types and structures

          1.2.1.1 Series

          1.2.1.2 Dataframe

            1.2.1.2.1 Inspecting a dataframe

          1.2.1.3 Schema

          1.2.1.4 Data types

        1.2.2 Expressions and contexts

          1.2.2.1 Expressions

          1.2.2.2 Contexts

            1.2.2.2.1 select

            1.2.2.2.2 with-columns

            1.2.2.2.3 filter

            1.2.2.2.4 group-by and aggregations

          1.2.2.3 Expression expansion

        1.2.3 Lazy API

      1.3 Expressions

        1.3.1 Expression expansion

          1.3.1.1 Function col

            1.3.1.1.1 Explicit expansion by column name

            1.3.1.1.2 Expansion by data type

            1.3.1.1.3 Expansion by pattern matching

            1.3.1.1.4 Arguments cannot be of mixed types

          1.3.1.2 Selecting all columns

          1.3.1.3 Excluding columns

          1.3.1.4 Column renaming

            1.3.1.4.1 Renaming a single column with alias

            1.3.1.4.2 Prefixing and suffixing column names

            1.3.1.4.3 Dynamic name replacement

          1.3.1.5 Programmatically generating expressions

          1.3.1.6 More flexible column selections

            1.3.1.6.1 Debugging selectors

        1.3.2 Categorical data and enums

          1.3.2.1 Data type Enum

            1.3.2.1.1 Creating an Enum

            1.3.2.1.2 Invalid values

            1.3.2.1.3 Category ordering and comparison

          1.3.2.2 Data type Categorical

            1.3.2.2.1 Creating a Categorical series

            1.3.2.2.2 Using Categories objects

            1.3.2.2.3 Lexical comparison with strings

            1.3.2.2.4 Combining categorical columns

          1.3.2.3 Performance considerations

            1.3.2.3.1 Encodings

            1.3.2.3.2 Enum encodings are fixed

            1.3.2.3.3 Categorical encodings

        1.3.3 Window functions

          1.3.3.1 Operations per group

          1.3.3.2 Mapping results to dataframe rows

            1.3.3.2.1 group_to_rows

            1.3.3.2.2 explode

            1.3.3.2.3 join

          1.3.3.3 Windowed aggregation expressions

          1.3.3.4 More examples

      1.4 IO

        1.4.1 CSV

          1.4.1.1 Read & write

          1.4.1.2 Scan

          1.4.1.3 Reading options

        1.4.2 Multiple files

          1.4.2.1 Reading into a single dataframe

          1.4.2.2 Reading and processing in parallel

      1.5 Interoperability

        1.5.1 Series to Racket values

        1.5.2 Iterating

        1.5.3 Columns as Racket data

        1.5.4 Numeric buffers

        1.5.5 Data for a plot

    2 Reference

      2.1 Operators and pipelines

        2.1.1 Shadowed bindings

      2.2 Series

        2.2.1 Converting to Racket values

        2.2.2 Categorical, Enum and Decimal

        2.2.3 dtype promotion

        2.2.4 Low-level Series API

      2.3 DataFrames

        2.3.1 Converting to Racket values

        2.3.2 Low-level DataFrame API

        2.3.3 Reading & writing

      2.4 Lazy frames

      2.5 Low-level expression API

        2.5.1 Eager expression contexts

      2.6 Generic interfaces

    3 Status