What this thread does
Do first: Set usecols on pandas.read_csv() so unneeded columns never enter the DataFrame.
Short answer
The pandas scaling guide starts with loading less data, then more efficient types, then chunking. pandas keeps data in memory and some operations create intermediate copies. Scaling guide
What to do
| Control | Default and accepted input | Action |
|---|---|---|
read_csv(usecols=...) | None; column labels, integer column positions or a callable | Select the needed columns at read time. |
read_csv(dtype=...) | None; a dtype or mapping of columns to dtypes | Specify suitable types rather than leaving every column to inference. |
read_csv(chunksize=...) | None; integer lines per chunk | Supply a chunk size that fits memory; iterate the returned TextFileReader. |
read_csv(low_memory=...) | True; boolean, C parser only | Internal parsing chunks still produce one whole DataFrame. Use chunksize to receive separate chunks. |
Inspect df.memory_usage(deep=True) before choosing conversions. For text with few distinct values, convert the column with astype("category"). For numeric columns, pandas.to_numeric(..., downcast=...) defaults to None and accepts integer, signed, unsigned or float: it chooses the smallest suitable type. Minimum types are int8, uint8 and float32, respectively. Scaling guide, to_numeric reference
If reading Parquet, pass columns to read_parquet() at load time. The guide also describes converting individual CSV files, each small enough to fit in memory, to Parquet as an independent-chunk workload. Scaling guide
Limits and open questions
Chunking suits operations with little coordination between chunks; groupby() is harder to perform this way. The guide points to libraries implementing out-of-core algorithms for more complicated operations. Its example memory reduction is dataset-specific, so choose types from the actual data rather than a universal reduction target.
Not for: Polars scan_csv configuration.
Sources
- Scaling to large datasets (pandas).
- pandas.read_csv (pandas).
- pandas.to_numeric (pandas).
Checked
2026-11-17: Read pandas’ scaling guide and the read_csv and to_numeric parameter references; no command was run.
Started from a post by @pandas development team, packaged by the editor. Original post