Connect any database. Ask in plain English.

Try free
← Blog

Pandas Read Large CSV: 15 Ways Timed, From 1.7 GB of Memory Down to 134 MB (2026)

One 534 MB CSV of 5 million invented rows, read into pandas 3.1.2 fifteen ways with each one's peak memory and time: defaults peaked at 1,672 MB in 1.1 seconds, usecols with dtype at 187 MB, chunksize with a running total at 134 MB, and engine="pyarrow" with dtype_backend="pyarrow" was fastest at 0.65 seconds. Plus Parquet, DuckDB and the options that quietly make it worse.

Fastero Dev TeamFastero Dev Team2026-12-02

We generated one CSV of 5 million invented orders (13 columns, 534 MB on disk) and read it into pandas 3.1.2 fifteen ways. Each way ran three times, each time in a fresh Python process, and we recorded the seconds and the process's peak memory with psutil. Every number below comes from those runs, on one Windows laptop.

The short answer: pd.read_csv() loads the whole file into memory, and with default settings our 534 MB CSV peaked at 1,672 MB. To read a large CSV, look first with nrows=100_000, then pass usecols for the columns you need and dtype with category for repeated text and small integer types: that read peaked at 187 MB. If you only need totals, chunksize=1_000_000 with a running total peaked at 134 MB. For speed, engine="pyarrow" with dtype_backend="pyarrow" read everything in 0.65 seconds. If you'll read the file again, convert it to Parquet once, or let DuckDB query the CSV directly. Checked 2 December 2026.

Fastero

Connect your database. Ask questions. Get dashboards.

Postgres, BigQuery, Snowflake, and 10+ sources — live-connected, AI-powered, no dashboard builder learning curve.

Try free →

The file, and how we measured

The CSV has 5,000,000 rows of invented orders: an order ID and a unique text reference, a date, a customer ID, region, country, channel, product and status as text, and quantity, unit price, discount and revenue as numbers. You can measure your own file the same way. We ran this script on it, with the file renamed orders.csv:

import time
 
import pandas as pd
import psutil
 
cols = ["region", "product", "quantity", "revenue"]
types = {"region": "category", "product": "category", "quantity": "int8"}
 
t = time.perf_counter()
df = pd.read_csv("orders.csv", usecols=cols, dtype=types)
seconds = time.perf_counter() - t
peak = psutil.Process().memory_info().peak_wset  # Windows only: the process's peak
print(f"{len(df):,} rows in {seconds:.2f} s, peak {peak / 2**20:,.0f} MB")
print(df.dtypes.astype(str).to_dict())
5,000,000 rows in 1.54 s, peak 188 MB
{'region': 'category', 'product': 'category', 'quantity': 'int8', 'revenue': 'float64'}

On Linux and macOS, the resource module's ru_maxrss gives the peak instead, in kilobytes on Linux and bytes on macOS. The benchmark's peaks include the 89 MB that Python, pandas and pyarrow take before reading anything. Times move between runs on a shared laptop (this one was faster than the 2.45-second median below), so the tables give medians of three runs with the range.

How much memory does pandas read_csv need?

About three times the file, with defaults. Our 534 MB file became an 808 MB DataFrame, and the read peaked at 1,672 MB in 1.12 seconds.

Part of that peak is new in pandas 3.1, whose C engine "reads sufficiently large files in parallel", in up to 6 threads. With one thread the same read took 3.20 seconds and peaked at 995 MB. The thread count "defaults to 1 when the process is limited to a single CPU", so on a 1-CPU machine you get the slower, smaller read automatically. Even that is quick by older standards: the 3.1 release notes say a "single-threaded read is typically two to three times faster than in 3.0".

Two settings make the peak worse:

  • low_memory=False, the usual answer to a DtypeWarning, peaked at 1,982 MB and took 3.35 seconds. The docs describe the default, low_memory=True, as: "Internally process the file in chunks, resulting in lower memory use while parsing, but possibly mixed type inference." Pass dtype for the mixed column instead.
  • Text as object, which is what pandas 2.x gives you, took 3.89 seconds and peaked at 1,463 MB. Why object text measures so differently is in pandas out of memory.

Take a first look with nrows

The docs describe nrows as "Number of rows of file to read. Useful for reading pieces of large files." Reading the first 100,000 rows took 0.09 seconds and peaked at 120 MB, and it's enough to estimate the full load:

import pandas as pd
 
first = pd.read_csv("orders.csv", nrows=100_000)
print(first.dtypes.astype(str).value_counts().to_dict())
per_row = first.memory_usage(deep=True).sum() / len(first)
 
with open("orders.csv", "rb") as f:
    rows = sum(1 for _ in f) - 1  # minus the header
print(f"{rows:,} rows; about {per_row * rows / 2**20:,.0f} MB once loaded with these types")
{'str': 7, 'int64': 3, 'float64': 3}
5,000,000 rows; about 808 MB once loaded with these types

The estimate matched the full read's 807.5 MB. Look at first.dtypes and first.nunique() too: they tell you which columns to skip and which text repeats enough to be a category.

Read only the columns you need with usecols

cols = ["region", "product", "quantity", "revenue"]
df = pd.read_csv("orders.csv", usecols=cols)

Four of the 13 columns gave a 235 MB DataFrame, and the read peaked at 369 MB. It was slower, though: 2.04 seconds against 1.12 for everything. In pandas 3.1 the parallel read needs "no options are passed that require parsing the file as a whole, such as iterator, chunksize, nrows, usecols, index_col, parse_dates" and a few more, so usecols reads with one thread. You trade under a second for 1.3 GB less memory.

Set dtypes when you read

types = {"region": "category", "product": "category", "quantity": "int8"}
df = pd.read_csv("orders.csv", usecols=cols, dtype=types)

Repeated text as category and quantity as int8 brought the DataFrame to 52.5 MB and the peak to 187 MB, in 2.45 seconds. Setting types at read time matters because converting afterwards needs the big version in memory first: in our out-of-memory tests, reading then converting peaked at 1,666 MB for a DataFrame that reading with the types set produced at a 378 MB peak. Dates are the exception to plan for: parse_dates also turns off the parallel read.

Read a CSV in chunks with chunksize

When you need a summary, not the rows, read the file a piece at a time and keep a running total:

totals = None
with pd.read_csv("orders.csv", usecols=cols, dtype=types, chunksize=1_000_000) as reader:
    for chunk in reader:
        part = chunk.groupby(["region", "product"], observed=True)["revenue"].sum()
        totals = part if totals is None else totals.add(part, fill_value=0)
 
by_product = totals.reset_index()

That peaked at 134 MB and took 3.19 seconds, and its 240 totals added up to 4,014,742,350.28, the same as reading the whole file and grouping it. The pandas docs: "As long as each chunk fits in memory, you can work with datasets that are much larger than memory."

Chunk size sets the peak, and barely moves the time. In a separate batch of three runs each:

Rows per chunk Peak memory Seconds
100,000 112 MB 2.08
250,000 115 MB 1.87
1,000,000 134 MB 2.15
2,500,000 195 MB 2.08

The 1-million-row read took 3.19 seconds in the main batch and 2.15 here: on a shared laptop, treat differences under a second as noise. Some notes from using it:

  • Combine with add(..., fill_value=0), not +, or a group missing from one chunk turns into NaN.
  • Sums, counts, minimums and maximums combine across chunks; medians and distinct counts don't. For those, and for sorts and joins across the whole file, use DuckDB (below).
  • To shrink the file instead, filter each chunk and write each one to its own Parquet file.

Faster reads: engine="pyarrow" and dtype_backend="pyarrow"

df = pd.read_csv("orders.csv", engine="pyarrow", dtype_backend="pyarrow")

The pandas docs say "In general, the pyarrow engine is fastest on larger workloads and is equivalent in speed to the C engine on most other workloads". On this file:

Read Seconds Peak memory DataFrame
Defaults (C engine, 6 threads) 1.12 1,672 MB 808 MB
engine="pyarrow" 1.25 2,038 MB 912 MB
engine="pyarrow", dtype_backend="pyarrow" 0.65 1,772 MB 626 MB
pyarrow engine with usecols and dtype 1.30 1,515 MB 52.5 MB

Three things stood out. With pandas 3.1's parallel C reader, the pyarrow engine alone was no faster. It parsed the date column into Python date objects, an object column, which made the DataFrame bigger. And it needed about 1.5 GB at its peak even when it returned only four columns: the pyarrow engine is a speed option, not a memory one.

Adding dtype_backend="pyarrow" fixed the dates (date32[day][pyarrow]) and gave the fastest read we measured. The docs still call this option "(still experimental)", and Arrow-backed columns can behave differently from NumPy ones in other libraries. The pyarrow engine also doesn't support chunksize or nrows, per the engine table in the pandas docs.

Connect any database. Ask in plain English.

Start free →

Convert the CSV to Parquet once

Apache Arrow's docs put it bluntly: "Due to the structure of CSV files, one cannot expect the same levels of performance as when reading dedicated binary formats like Parquet." If you'll read the file more than once, pay for the parse once:

pd.read_csv("orders.csv", parse_dates=["order_date"]).to_parquet("orders.parquet")

That took 7.64 seconds, peaked at 972 MB, and wrote a 128 MB file, a quarter of the CSV. After that:

df = pd.read_parquet("orders.parquet", columns=["region", "product", "quantity", "revenue"])
Read from Parquet Seconds Peak memory DataFrame
All 13 columns 0.38 1,407 MB 760 MB
4 columns 0.24 516 MB 235 MB

A Parquet file stores each column's type, so the dates came back as dates, and reading four columns reads only those four. If the CSV is already too big for pandas, DuckDB can convert it without loading it into a DataFrame. The DuckDB team lists "Reading data from one file and writing to another (e.g., reading from CSV and writing to Parquet)" among the jobs its streaming engine handles; on this file it took 3.15 seconds and peaked at 1,160 MB with 16 threads:

import duckdb
 
duckdb.sql("COPY (FROM read_csv('orders.csv')) TO 'orders-duckdb.parquet' (FORMAT parquet)")

Its file was 139 MB, and pandas read its DATE column back as Python date objects, so set the type you want in the SQL if that matters.

Let DuckDB read the CSV directly

When the goal is a summary, DuckDB can query the CSV where it is and hand pandas only the result:

import duckdb
 
by_product = duckdb.sql("""
    SELECT region, product, sum(revenue) AS revenue
    FROM read_csv('orders.csv')
    GROUP BY ALL
""").df()

It took 1.03 seconds, peaked at 590 MB, and returned the same 240 totals. On the Parquet file, the same query took 0.23 seconds and peaked at 160 MB. DuckDB's docs say its "CSV reader can automatically infer which configuration flags to use by analyzing the CSV file using the CSV sniffer", and read_csv takes column types when it guesses wrong. Joins, sorts and medians that chunksize can't do work the same way, and DuckDB can spill to disk when they outgrow memory; pandas out of memory has a measured run under a 200 MB limit, and DuckDB in Python and DuckDB vs pandas cover the rest.

All 15 ways, measured

Two bar charts side by side, peak process memory and seconds, for fifteen ways of reading a 534 MB CSV: read_csv defaults 1,672 MB and 1.12 s, one thread 995 MB and 3.20 s, low_memory=False 1,982 MB, usecols with dtype 187 MB, chunksize 134 MB, pyarrow engine with pyarrow dtypes 1,772 MB and 0.65 s, read_parquet of 4 columns 516 MB and 0.24 s, DuckDB on the Parquet 160 MB and 0.23 s

Peak memory and time for each way of reading the same 534 MB CSV, median of three runs. Invented data, one laptop.

Method Peak memory Seconds (range) Result in pandas
read_csv() defaults 1,672 MB 1.12 (0.92 to 1.69) 808 MB DataFrame
Defaults, one thread 995 MB 3.20 (2.38 to 4.83) 808 MB
low_memory=False 1,982 MB 3.35 (2.92 to 3.39) 808 MB
Text as object (pandas 2.x) 1,463 MB 3.89 (3.28 to 4.85) about 812 MB
nrows=100_000 120 MB 0.09 (0.09 to 0.10) 16 MB
usecols, 4 columns 369 MB 2.04 (1.34 to 2.18) 235 MB
usecols and dtype 187 MB 2.45 (2.33 to 2.48) 52.5 MB
chunksize with a running total 134 MB 3.19 (2.44 to 3.57) 240 totals
engine="pyarrow" 2,038 MB 1.25 (1.24 to 1.38) 912 MB
pyarrow engine and backend 1,772 MB 0.65 (0.62 to 0.69) 626 MB
pyarrow engine, usecols, dtype 1,515 MB 1.30 (1.28 to 1.53) 52.5 MB
read_parquet(), all columns 1,407 MB 0.38 (0.36 to 0.43) 760 MB
read_parquet(), 4 columns 516 MB 0.24 (0.24 to 0.27) 235 MB
DuckDB on the CSV 590 MB 1.03 (0.96 to 1.06) 240 totals
DuckDB on the Parquet 160 MB 0.23 (0.22 to 0.27) 240 totals

The machine: an Intel Core i7-11800H laptop (8 cores, 16 threads) with 64 GB of RAM and an NVMe SSD, on Windows 11, with pandas 3.1.2, pyarrow 26.0.1, DuckDB 2.0.1 and Python 3.14.3. The file was in the operating system's cache, so these are parsing times, not disk times. The object row's DataFrame is what the process held; memory_usage(deep=True) reported 2,176 MB for it.

Reading big files on a small machine, or a bigger one for an hour

Fastero is an AI and data platform where people and AI agents work together on a team's data. Its notebooks are standard .ipynb files with pandas installed, and they read the project's uploaded files by path. What matters for a large CSV is the machine:

  • Standard is 1 CPU and 2 GB for a notebook server. With one CPU, pandas reads with one thread; in our one-thread test this file's default read peaked at 995 MB, which fits but leaves little room, and with usecols and dtype the peak was 187 MB. Use the methods above first; they're free.
  • On Pro, a notebook can move to a bigger machine: Medium 2 CPUs and 8 GB at $0.20 an hour, Large 4 CPUs and 16 GB at $0.40, Extra large 8 CPUs and 32 GB at $0.80. It's charged by the second from money added to the balance, not from Pro's $20 per editor a month, so a one-off load of a big file costs cents.
  • Files you upload count toward storage: 500 MB on Free, 5 GB per editor on Pro.
  • If the data is in a database, skip the CSV. A SQL cell runs on a saved Postgres, MySQL, SQL Server, Redshift, Oracle or BigQuery connection with its stored credentials and lands in Python as a DataFrame named after the cell, so the database does the GROUP BY and pandas gets 240 rows.

A Fastero notebook with a matplotlib cell drawing a horizontal bar chart of twelve invented solar sites' output as a share of forecast, coloured by region

A notebook in Fastero's editor charting a pandas DataFrame. Invented sample data.

Plans and machine prices are on the pricing page.

FAQ

How do I read a large CSV in pandas without running out of memory?

Pass usecols for the columns you need and dtype with category for repeated text and small integer types; on our 534 MB file that cut the peak from 1,672 MB to 187 MB. If you only need totals, read with chunksize and keep a running total. If it still doesn't fit, query the file with DuckDB.

What chunksize should I use in pandas read_csv?

One that keeps a chunk well inside your free memory: 1,000,000 rows of four columns peaked at 134 MB here, and 100,000 rows at 112 MB. Time stayed around 2 seconds from 100,000 to 2,500,000 rows per chunk, so pick by memory. Measure one chunk with memory_usage(deep=True) and scale from there.

Is engine="pyarrow" faster than the default?

Not by itself on pandas 3.1, whose default C engine now reads large files in parallel: 1.25 seconds against 1.12. With dtype_backend="pyarrow" as well it was the fastest read we measured, at 0.65 seconds, but its peak memory was higher than the default's.

Why is read_csv slower with usecols?

In pandas 3.1, options that need the file parsed as a whole, including usecols, nrows, chunksize and parse_dates, turn off the parallel read. Our usecols read took 2.04 seconds against 1.12 for the whole file, but peaked at 369 MB instead of 1,672 MB.

Does low_memory=False use more memory?

Yes. It peaked at 1,982 MB on our file, against 1,672 MB with the default, and took three times as long. It's usually set to silence a mixed-type warning; giving that column a dtype fixes the warning without the cost.

Should I convert my CSV to Parquet?

If you'll read it more than once, yes. Converting took 7.64 seconds once; afterwards, reading four columns took 0.24 seconds instead of 2.04, and the file was 128 MB instead of 534 MB. Parquet also keeps each column's type, so dates come back as dates.

Sources

Read on 2 December 2026.


Try Fastero free: pandas notebooks that read your uploaded files or query your database, with a 16 GB machine on Pro for $0.40 an hour when a file needs it. No credit card required.

Ready to try it yourself?

Connect your database, ask questions in plain English, and get live dashboards — in under 2 minutes. No credit card required.

Follow Fastero on LinkedIn for new articles and examples.

Keep reading

Related articles

2026-12-03

Sample CSV File Download: 9 Free Test Files, 100 to 10,000 Rows, 15 Edge Cases Tested (2026)

Nine free sample CSV files of invented data: orders with 100, 1,000 and 10,000 rows, 1,000 customers, 731 days of metrics, and four test files with quoted commas, line breaks, NULL markers, leading zeros, big integers, a BOM, semicolons and broken rows. We read each with pandas 3.1.2, DuckDB 2.0.1, Python's csv module and PostgreSQL 16 COPY: pandas changed 6 of 15 edge cases without an error, DuckDB 1.

csvsample-datapandas

2026-12-02

Pandas Out of Memory: Measure the DataFrame, Then Cut It From 808 MB to 181 MB (2026)

We loaded 5 million invented orders into pandas 3.1.2 and measured each fix: categories, parsed dates and smaller numbers took the DataFrame from 808 MB to 181 MB, and setting the types while reading kept the peak at 378 MB instead of 1,666 MB. Plus the operations that multiply memory (a merge on a repeated key tripled the rows, apply(axis=1) added 516 MB) and what to use when the data still doesn't fit.

pandaspythonmemory

2026-12-02

Dask vs pandas: When Dask Helps, When It Is Slower, and One Groupby Timed in pandas, Dask, Polars and DuckDB (2026)

What Dask DataFrame is, when it beats pandas and when it is slower, and the pandas habits that behave differently in Dask, with real output. The same groupby on 30 million rows took 4.91 s in pandas 3.1.2, 1.48 s in Dask 2026.11.0, 0.16 s in Polars 2.2.0 and 0.25 s in DuckDB 2.0.1, and Dask used almost as much memory as pandas.

daskpandaspolars