Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 Β· Getting Started

What Is Polars?

Learn what Polars is, how its Rust engine, expressions and lazy evaluation differ from other DataFrame tools, and when to choose it for your data work.

Polars is a DataFrame library: a tool for loading, cleaning, reshaping and summarizing tables of data. You use it from Python (there are also Rust, JavaScript and R front ends), but the engine underneath is written in Rust. That engine stores data in a columnar layout based on the Apache Arrow memory format, spreads work across all CPU cores, and can plan a whole query before running it.

If you have used spreadsheets or SQL, the idea is familiar: rows are records, columns are fields, and you ask questions such as "total revenue per region". What makes Polars stand out is how you ask. Instead of poking at a table one step at a time, you describe the result you want with expressions, and Polars decides how to compute it quickly.

On this site every example runs in your browser. The first time you press Run, the page downloads the Polars package (a WebAssembly build), so the first run takes a few seconds. Browser builds are single-threaded and have no network, so some features (multi-core speed-ups, reading from URLs and cloud storage) are explained in read-only snippets, and we say so each time.

Why people choose Polars

Fast Rust engine, multi-core
Columnar Arrow-style memory
Query planner Lazy mode optimizes
Expressions Readable, composable

Speed comes from the design, not tricks

1 / 2

A first look

Install Polars with pip install polars on your own machine. In the editor below it loads automatically when you import it. The code creates a tiny table, then asks for the average price per fruit.

Python Your first Polars program

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice what you did not write: no loop, no index, no row-by-row logic. pl.col("price").mean() is an expression: a recipe that says "take the price column and average it". The group_by(...).agg(...) call runs that recipe once per group. You will meet expressions properly in Expression Basics.

What makes Polars different

Columnar storage

A Polars DataFrame keeps every column as one contiguous block of values of a single type. Summing a column then means walking through one tight block of numbers, which modern CPUs do very quickly and can process several values at a time. Row-oriented tools (a list of Python dictionaries, for example) scatter the values of one column across memory.

Parallelism

Independent work is split across cores. When you ask for five expressions in one select, Polars can evaluate them at the same time. Group-bys, joins, sorts and file readers are parallel too. (In your browser this is limited to one thread, so the speed-up shows up on real hardware.)

A strict, predictable type system

Every column has one data type, such as Int64, Float64, String, Date or Boolean. There is no hidden "object" type that quietly turns a column into slow Python values. Missing data is a proper null value that works in every type. Types are covered in Data Types.

No index

Polars has no row index. A row is identified by its position, and you pick rows with filters on column values. That removes a whole family of alignment surprises, and it makes the API smaller.

Immutable results

Operations return a new DataFrame; they do not change the old one in place. You will see this in code as chains of method calls, each returning something new.

Eager and lazy

Polars offers two front doors:

  • A DataFrame is eager. Each call runs immediately, like a normal Python function.
  • A LazyFrame is lazy. Calls only record what you want. Nothing happens until you call .collect(), at which point Polars optimizes the whole plan: it skips columns you never use, pushes filters down toward the data source, and removes duplicate work.
Python Eager versus lazy

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both produce the same table. For small data the difference is invisible, but with large files lazy mode can be dramatically faster and use far less memory. The full story is in Lazy Frames: the Basics.

How Polars compares to other tools

  • pandas is the long-standing Python standard. Its API is huge and flexible; Polars is smaller, more consistent and usually faster on large data. If you know pandas, the chapter "Migrating from pandas" later in this track maps one to the other.
  • SQL databases are great for storage and shared access. Polars is a library inside your program: no server, and results come back as Python objects. Polars can even run SQL against a DataFrame.
  • Spark spreads work over many machines. Polars targets a single machine, where it handles data far larger than people expect, including data bigger than memory with its streaming engine.

Polars is a young, fast-moving library. Method names and defaults have changed over time (for example groupby became group_by, and apply became map_elements). This track uses version 1.x names, the same ones the in-browser runner has. When you read older blog posts, expect small differences.

When to choose Polars

Reach for Polars when your data is more than a few hundred thousand rows, when you build repeatable pipelines, when you want clear, chainable code, or when you read large CSV or Parquet files. For a quick glance at ten rows, any tool will do; the benefits grow with the size and complexity of the job.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What language is the Polars engine written in?

    The engine is written in Rust. Python is only a front end that builds expressions and calls into it.
  2. 2. In Polars, when does a LazyFrame actually compute a result?

    A LazyFrame records a plan. The plan is optimized and run when you call collect() (or another action such as a sink).
  3. 3. Which statement about Polars DataFrames is true?

    Polars has no row index, each column has a single type, and missing data is a real null. Operations return new frames.
  4. 4. What does pl.col('price').mean() represent?

    pl.col(...).mean() builds an expression. It only produces a value when used inside a context such as select, with_columns or agg.

Summary

  • Polars is a Rust-powered DataFrame library with a Python API, columnar storage and multi-core execution.
  • You describe results with expressions; Polars decides how to compute them.
  • Columns have one strict type and a real null for missing data; there is no row index.
  • DataFrame is eager, LazyFrame is lazy and optimized on collect().
  • The browser runner is single-threaded, so speed-ups from parallelism show on real hardware.

Next: Your First DataFrame