Guide · Open source
How to use Polars: install, lazy queries and tips
Updated · written with AI from the project's own documentation and checked against our catalogue data
Polars is an open-source query engine for DataFrames, which are tables of rows and columns used to clean, filter, group and summarize data. It is written in Rust and can be used from Python, Rust, Node.js, R, or SQL. This guide shows you how to install it, write a lazy query against a Parquet file and understand when the streaming engine helps.
Quick start
- 1Check Python is installed. Polars is installed from PyPI and requires Python. Confirm Python is available on your machine before you continue.
- 2Install Polars. Run pip install polars in your terminal to get the latest version.
- 3Import Polars. In your script, import it with import polars as pl, the usual alias in the README examples.
- 4Point scan_parquet at your file. Use pl.scan_parquet with the path to your Parquet file to create a lazy query without loading everything at once.
- 5Build the query. Chain filter, group_by, agg and sort calls using expressions like pl.col and pl.len.
- 6Run the query. Call collect() to execute. For data larger than memory, use collect(engine='streaming').
What Polars is and who it suits
Polars is an analytical query engine for DataFrames. The project describes it as designed to be fast, easy to use and expressive.
It fits Python users who analyze large CSV or Parquet files and find slower tools too slow, data analysts who want lazy queries the engine can optimize before running, and developers who want a native Rust DataFrame library.
- Not a good fit if you only need a spreadsheet-style tool; a GUI spreadsheet is simpler.
- The README does not claim drop-in compatibility with pandas, so check your existing code before migrating.
- GPU support is described only for NVIDIA GPUs.
Install Polars with pip
Polars is installed from PyPI. The prerequisite is Python. Install the latest version with the command below, then import it as polars in your code.
For optional dependencies, the project's User Guide has details on feature flags. The Installation guide covers more advanced cases, such as expecting more than 2^32 rows, running on an old CPU, or using an x86-64 build of Python on Apple Silicon under Rosetta.
pip install polarsRun a lazy query on a Parquet file
Polars queries are built from expressions. Using scan_parquet creates a lazy query rather than reading the whole file at once. The engine optimizes the query and runs it in parallel across available cores when you call collect.
The example filters rows where status is shipped, groups by customer_id, sums the amount as total, counts rows as n_orders, and sorts by total in descending order.
- scan_parquet is lazy; nothing is read until collect() runs.
- pl.len() counts rows in each group.
- The example uses a file named orders.parquet; replace it with your own file.
import polars as pl
df = (
pl.scan_parquet("orders.parquet")
.filter(pl.col("status") == "shipped")
.group_by("customer_id")
.agg(
pl.col("amount").sum().alias("total"),
pl.len().alias("n_orders"),
)
.sort("total", descending=True)
.collect()
)Process data larger than memory with streaming
If your data does not fit into memory, Polars can process the query, or parts of it, in a streaming fashion. The README says this drastically reduces memory requirements, and gives the example of processing a 250GB dataset on a laptop. Its claim is that this may be possible, not a guarantee.
To run a query in streaming mode, collect it with engine='streaming'.
df = lazy_query.collect(engine="streaming")Install Polars from source (optional)
Most users should use pip. The README also describes compiling from source for bleeding-edge releases or maximum performance. This requires the Rust compiler and maturin, and is done from the py-polars directory with one of several make targets.
By default the build is optimized for a modern CPU. Set LTS_CPU=1 if your CPU is older and lacks AVX2.
- Install the Rust compiler from rust-lang.org.
- Install maturin with pip install maturin.
- Run cd py-polars, then choose a make target such as make build or make build-release.
pip install maturinWhere to go next
The official User Guide at docs.pola.rs is the main reference. The API reference for Python, Rust, Node.js and R is linked from the README. Polars also supports I/O and Expression plugins for custom code, and the contributing guide covers how to help with the project.
For datasets that outgrow one machine, the README points to a guide on horizontally scaling Polars queries on a cluster.
- Python API reference: docs.pola.rs/api/python/stable/reference/index.html
- Rust API reference: docs.rs/polars/latest/polars/
- Discord for help: discord.gg/4UfP5cfBE7
What people use it for
- Summarizing order totals per customer from a large Parquet file, as in the README example.
- Filtering and sorting big CSV or Parquet exports in Python faster than slower tools allow.
- Processing a dataset larger than your computer's memory using the streaming engine.
- Building a native data-processing tool in Rust with the polars crate.
- Querying tables from Node.js, R, or SQL, since these bindings are listed in the README.
Frequently asked questions
How do I install Polars?
Run pip install polars. The prerequisite is Python, and Polars is installed from PyPI. The User Guide covers optional dependencies and feature flags.
Is Polars free to use?
Yes. Polars is licensed under the MIT License, identified as MIT in the SPDX format. Check the LICENSE file in the repository for the full terms.
Does Polars run on large datasets that don't fit in RAM?
Yes, the README says the streaming engine can process queries, or parts of them, without loading everything into memory. It gives a 250GB example, and you can run it with collect(engine='streaming').
Is Polars a drop-in replacement for pandas?
No, the README does not claim drop-in compatibility with pandas. If you have existing pandas code, test it carefully before switching.
Does Polars support GPUs?
The README says Polars can optionally accelerate queries on NVIDIA GPUs. It does not mention support for other GPU hardware.
What are alternatives to Polars?
Projects often compared with Polars include pandas, DuckDB, Apache DataFusion and Dask. Pick based on your language, data size and whether you need a SQL interface or a pandas-style API.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Polars suits Python and Rust users who work with large CSV or Parquet files and want lazy, optimized queries and a streaming engine for data bigger than memory. If you need a spreadsheet-style tool, or you depend on a pandas-compatible API for existing code, a different tool such as pandas or a GUI spreadsheet is likely the better choice.
Install options & downloads