
Chris Parmer
2026-11-16
Polars demo
Fast DataFrames for large data in Python, with Dash and Plotly
TL;DR
- Polars is a DataFrame library for Python with its query engine written in Rust, started by Ritchie Vink in 2020. You describe a query once, and Polars plans it, reads only the columns and row groups it needs, and runs it on every core. Version 2.2.0 came out on November 24, 2026, with SQL that changes tables and joins that spill to disk; we tested it in Polars 2.2: hands-on in Dash.
- It suits Dash apps over event and time series data that's too big to load whole: smart meter reads, trades, sensor and test logs, claims, adverse event reports, and trips.
- With a coding agent you don't need the API by heart. Describe the question and name the capability, such as scan_parquet, group_by_dynamic, or join_asof, and the agent writes the query. This demo shows what's possible and gives the prompts we used.
- Our example is Fleet Ops, a Dash app for a taxi fleet on 21.2 million NYC yellow taxi trips, where every chart is a lazy query that runs when someone moves a control.

What is Polars?
Operational data piles up fast. A utility logs a meter read every 15 minutes, a trading desk logs every fill, a test bench writes a reading per channel every second, and a taxi fleet logs millions of trips a month. An app over that data has to answer a question like "how busy was last Tuesday at 6 p.m.?" right after someone clicks, on a server with a few gigabytes of memory, and our six months of trips alone take 668 MB in memory if you load every column.
Polars handles this with a lazy API. pl.scan_parquet returns a LazyFrame, a description of a query rather than data. You chain filters, joins, and aggregations onto it, and nothing is read until you call collect(). At that point Polars optimizes the whole query: filters move into the file scan so row groups outside your date range are skipped, and only the columns the query uses are read. What comes back is the small table your chart needs.
We also recommend DuckDB for loading data in new apps. Our overview of Python packages for data shows where both fit with the rest of the stack.
What's possible
Tell your coding agent to use Polars, and name the capability that fits your question:
- Lazy scans: pl.scan_parquet over a folder of files, with filters pushed into the scan.
- Time buckets: group_by_dynamic per hour, day, or week, and rolling for moving windows.
- Nearest-in-time joins: join_asof to attach the weather, price, or sensor value in effect at each timestamp.
- Group statistics: group_by(...).agg(...) with quantile and median, and .over() for shares within a group.
- Reshaping: pivot and unpivot for the grids a heatmap needs.
- Memory control: collect(engine="streaming") and sink_parquet.
- SQL: pl.sql or a SQLContext when a query is easier to write in SQL, on the same lazy frames. Since 2.2, pass values with params= and change registered tables with INSERT and UPDATE.
- Warehouse tables: the polars-bigquery connector's scan_table for data in Google BigQuery (see our polars-bigquery demo).
- Seeing the plan: LazyFrame.explain().
Demo App: Fleet Ops
Fleet Ops is the app an operations team at a taxi or ride-hail fleet would want: when and where demand is, where riders go, and how long the airport runs take. Swap trips for meter reads or fills and the same patterns work for a utility or a trading desk. It runs on public data:
- Trips: NYC Taxi and Limousine Commission (TLC) yellow taxi trip records, April to September 2026, six monthly Parquet files.
- Zones: the TLC taxi zone lookup table and zone shapes.
- Weather: hourly Central Park weather from the Open-Meteo archive.
This prompt sets up the data:
Prompt: Use Polars to prepare NYC TLC yellow taxi trips for April to September 2026 from d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_YYYY-MM.parquet. For each month, scan_parquet, keep pickup and dropoff times, pickup and drop-off zone, miles, fare, tip, total and payment type with small dtypes, add trip minutes, drop trips under 1 minute or over 3 hours, under 0.1 miles and with non-positive fares, sort by pickup and sink_parquet one clean file per month. Also download the taxi zone lookup and shapefile (convert to GeoJSON) and hourly Central Park precipitation from the Open-Meteo archive.
The June to September files add a request_source column, so scanning the raw files together fails until each month is cleaned to the same columns. After that, the core of every page is a filtered lazy scan:
def base(start, end, borough=None):lf = pl.scan_parquet(["trips_2026-04.parquet", ..., "trips_2026-09.parquet"])lf = lf.filter(pl.col("pickup") >= start, pl.col("pickup") < end + timedelta(days=1))if borough:lf = lf.filter(pl.col("pu").is_in(zone_ids[borough]))return lf # nothing has been read yet
Demand
The Demand tab, shown at the top, is the overview an operations lead would start from: totals for the chosen dates, trips over time against Central Park rain, and a weekday by hour heatmap that shows when the city is busiest. Each chart is one lazy query.
Prompt: Build a Dash app called Fleet Ops on those files. Demand tab: a date range, a pickup borough and an hour/day/week bucket. Show KPI cards (trips, total fares, median trip minutes and miles, tip rate on card payments, query time), trips over time with Polars group_by_dynamic, Central Park rain as bars matched to each bucket with join_asof, and a weekday by hour heatmap of average trips per hour made with group_by and pivot. Every callback builds a lazy query and collects it with engine="streaming".
Two weeks of June, hour by hour

Narrowing the dates to two weeks and the bucket to an hour, the page's three queries took 172 ms together, because the date filter lets Polars skip row groups outside the range. The rain bars come from join_asof, which attaches the weather in effect at each hour, the same join you'd use to attach a price or a sensor reading.
Zones

The map colors each of the 263 taxi zones by pickups, median fare per mile, or card tip rate, for any range of hours and days, all from one group_by on pickup zone. Clicking a zone lists where its riders went, which tells a fleet where its cars end up after each run.
Prompt: Zones tab: a choroplethmap of the TLC taxi zones colored by pickups (log scale), median fare per mile or card tip rate, from one Polars group_by on pickup zone joined to the zone lookup. Add an hour range slider and weekday/weekend filter. Clicking a zone (or picking it in a dropdown) shows a bar chart of its top 10 drop-off zones with share of trips and median minutes.
Airport runs

Airport trips set a fleet's schedule, so this tab shows how long they take by pickup hour, with the median and 90th percentile from Polars quantile. A weekday trip from JFK to Manhattan takes more than twice as long at 3 p.m. as at 3 a.m., while the flat airport fare stays about the same, so the money per minute on the meter falls through the day.
Prompt: Airport runs tab: pick JFK, LaGuardia or Newark, a drop-off borough and weekdays/weekends. One Polars group_by on pickup hour returns trips, the median and 90th percentile trip minutes (quantile), the median total fare and total fares divided by total minutes. Show the fastest and slowest hour as KPI cards, a line chart of the two percentiles, and fares per minute.
Data definitions

The last tab is the app's semantic layer, the page you'd point an analyst or an auditor to when they ask how a number was computed. It lists every metric and dimension in Fleet Ops with a plain definition and the Polars expression behind it, starting with the rule for which trips count. The charts build their queries from those same expressions, so the page can't drift from what the app computes. Below the definitions, the optimized plan for any chart, from LazyFrame.explain(), shows whether its filters reach the Parquet scan. For more on keeping metric definitions in one place, see our guide to semantic layers in Dash Enterprise.
Prompt: Data definitions tab: keep every metric (trips, fares collected, median trip minutes and miles, card tip rate, fare per mile, trip time percentiles, fares per meter minute) as Polars expression code in one module, and build every chart's query from it. List the metrics and the dimensions (pickup time and hour, weekday or weekend, zone, borough, airport, payment type, rain) with a plain definition, the tabs that use each one, and the expression, plus the filter that decides which trips count. Below them, a chart picker that shows LazyFrame.explain() for the last run of that chart, with its time and row count.
Other apps you can build with Polars
- Energy: a smart meter analytics app that buckets millions of 15-minute reads per feeder with group_by_dynamic and flags transformers running hot.
- Finance: a transaction cost app that matches each fill to the quote in effect with join_asof and sums slippage by venue and hour.
- Pharma: a pharmacovigilance explorer over FDA adverse event reports, with lazy filters by drug and reaction and pivot for drug-by-reaction tables.
- Engineering: a test-bench log viewer that scans a folder of Parquet runs and computes rolling statistics per channel.
- Science: a lab instrument app that pivots long sensor readings into one column per instrument with pivot and compares runs side by side.
What's new in Polars 2.2
Polars 2.2.0 was released on November 24, 2026. We added a Borough report page to Fleet Ops that runs on Polars SQL to try it, in Polars 2.2: hands-on in Dash:
- Joins can now spill to disk when they don't fit in memory, which finishes the out-of-core work that started in 2.0. In the words of Polars creator Ritchie Vink: "as of Polars 2.2 all pipeline blockers can spill to disk."
- SQL can change registered tables with INSERT, UPDATE, DELETE, and COPY, and gained views, macros, query parameters, and PIVOT.
- Iceberg tables can be written and maintained from SQL, and pl.scan_database reads databases lazily.
- 111 performance pull requests; on Fleet Ops, value_counts with sorting ran about 3.4 times faster than on 2.1.
The Polars team's announcement lists six changes to check before you upgrade. For 2.1, see What's new in Polars 2.1.
Running Polars on Plotly Cloud and Dash Enterprise
What we learned deploying Fleet Ops, which applies the same way on Dash Enterprise:
- Keep the files small. The app downloads and cleans the six months on first start. Without a persistent filesystem the files sit on the container's own disk, which counts against the app's memory, so we keep only the columns the app uses and write them with zstd compression, which took the cleaned files from 398 MB to 297 MB. With a persistent filesystem (/data), put them there instead. Small reference files, such as the zone shapes and the weather, ship with the app.
- Collect lazily and stream. Callbacks only collect the small result a chart needs, with engine="streaming", instead of holding every trip in memory.
- Don't make a request wait for the download. Our first deploy had callbacks wait until the data was ready. Gunicorn kills a worker whose request runs past 30 seconds, and the download thread died with it, so the data never finished. Now the callbacks return right away, a banner says the data is being prepared, and the charts fill in when it's done.
- Import heavy libraries at startup. Locally, a callback failed once because two threads imported NumPy for the first time at the same moment. Importing it at the top of app.py fixed it.