Why a 4GB client CSV can choke a 16GB laptop
pandas loads everything before it starts work; Polars' scan_csv plans the query first and reads only the columns and rows the answer requires.
In brief
- pandas' own documentation acknowledges that data taking up a sizable share of RAM is already hard to handle, because some operations make intermediate copies.
- Polars' scan_csv and scan_parquet read lazily, so filters and column selection are applied as the file is read.
- The streaming engine runs queries in batches, handles data larger than RAM and, according to Polars, is also faster than the in-memory engine.
A 4 GB file can exhaust the memory of a 16 GB laptop after a few pandas transformations. Take a hypothetical first working session with a logistics client. They hand over a folder of several dozen CSV files, a few gigabytes in all, and ask which warehouse had the worst delivery delays last month. You open a notebook and type pd.read_csv. The fan roars and the cursor keeps spinning while the whole room waits for your answer.
None of this reflects on your skill. It is the limit of eager reading, which loads all the data into memory before any processing begins.
Polars takes a different approach: plan the query first, read the data afterward. For an FDE, that is the skill that lets you answer a client during the meeting instead of promising a reply next week.
Why does pandas buckle before a file is as big as RAM?
The official pandas documentation says plainly that working with larger-than-memory data is difficult. It also acknowledges that data taking up only a sizable share of RAM is already unwieldy, because some pandas operations need to make intermediate copies. That is why 4 GB of data can overwhelm a 16 GB machine.
pandas has workarounds of its own. Loading only the columns you need cuts memory use to about 1/10 in an example from its documentation, but not every file format supports this.
You can also read in chunks, although the same documentation notes that operations such as groupby are much harder to do chunk by chunk. And “which warehouse is latest?” is a groupby question.
Reading lazily means reading less
Polars describes itself as a high-performance DataFrame library for Python and Rust, with a core written in Rust. What matters most to an FDE is its lazy mode. The scan_csv function reads CSV lazily and accepts many files at once through a glob pattern such as data/*.csv. Beyond CSV, Polars has scan_ functions for IPC, Parquet and JSON.
When you call scan_csv, Polars does not yet load all the data into memory. It records what you want to do as a query plan. The optimizer can then use predicate pushdown, which applies filter conditions as early as possible, while the file is being read.
It also uses projection pushdown, which reads only the columns that are needed. According to the scan_csv documentation, this can reduce memory use.
The client’s question, written as a query
Back to the late warehouses. Say each file has 40 columns but you need only three: warehouse, delivery date and minutes late. Say also that “last month” is September 2026 and that the date column is stored as a YYYY-MM-DD string.
import polars as pl
q = (
pl.scan_csv("deliveries/*.csv") # only plans; does not load all the data yet
.with_columns(pl.col("delivery_date").str.to_date("%Y-%m-%d"))
.filter(
pl.col("delivery_date").is_between(pl.date(2026, 9, 1), pl.date(2026, 9, 30))
)
.select(["warehouse", "delivery_date", "minutes_late"])
.group_by("warehouse")
.agg(pl.col("minutes_late").mean().alias("avg_delay"))
.sort("avg_delay", descending=True)
)
result = q.collect(engine="streaming") # the query actually runs here
Two small details decide whether the result answers the question that was asked. The filter has both a lower and an upper bound, so it keeps exactly one month instead of everything from September to now. And the date column is converted to a date type before the comparison, so a row written as 2026-9-5, or one with a time attached, does not silently slip through a string comparison.
The rest relies on the two mechanisms above. Projection pushdown skips the other 37 columns as the files are read. Predicate pushdown discards rows outside September before they go any further. The final result has one row per warehouse, small enough for a slide.
Parquet can skip whole pages of data
If the client supplies Parquet, the job gets easier. scan_parquet lazily reads Parquet files stored locally or in the cloud, and pushes filters and column selection down to the reading step just as scan_csv does. The difference is that Polars can read the statistics stored in a Parquet file, so it can skip pages of data that cannot match the filter.
On a project that runs for several weeks, then, one early step pays off: converting the client’s raw CSV to Parquet once.
pl.scan_csv("deliveries/*.csv").sink_parquet("deliveries.parquet")
# from here on, every new question starts with:
q = pl.scan_parquet("deliveries.parquet")
After that, each new question reads only the relevant data instead of scanning all the raw CSV again.
When the data really is larger than RAM
Lazy reading helps you read less, but sometimes the part you need is still bigger than memory. This is where the streaming engine comes in: Polars runs the query in batches, which lets it process data that does not fit in RAM.
The Polars documentation says this engine is faster than the in-memory engine as well as lighter on memory. Measure it on the client’s real data before making any promises about speed.
Polars has limits you should know in advance. Its benefits depend on writing queries that leave the optimizer room to work. Nor is it a rewrite of pandas, so the pl.col(...) expression syntax takes some getting used to.
Which mistakes cancel out the benefits of lazy reading?
Most early mistakes with Polars come from habits carried over from pandas, rather than from the library. Check for the following before running a query on client data.
| Common mistake | Consequence | Fix |
|---|---|---|
Calling collect() right after scan_csv, then filtering |
The whole file is loaded into memory, just as with pandas | Write all the filter, select and group_by steps first, then collect |
Using read_csv out of habit |
There is no plan to optimize | Switch to scan_csv or scan_parquet |
| Filtering “last month” with only a lower bound | Data from the current month gets mixed in | Use is_between with both bounds |
| Comparing dates as strings | Rows in an inconsistent format are filtered incorrectly, with no error | Convert the column to a date type before filtering |
| Rescanning raw CSV for every question | Every run reads all the data again | Convert to Parquet once, at the start of the project |
What to learn first
Start with lazy thinking: understand how scan_ differs from read_, filter and select early, and collect only at the final step. Then learn Parquet and streaming. When you apply for jobs, a bare “knows Polars” on your resume is not enough.
Write a line with numbers in it, such as how many gigabytes you processed, on a machine with how much RAM, and how far peak memory fell. Then put the comparison notebook on GitHub.
A comparison with concrete measurements shows a hiring manager that you have done the work, which a list of keywords struggles to prove.
Your laptop does not need to be more powerful. You need the habit of reading only the data that the client’s question requires.
Was this article useful?
Thanks for the feedback!