pandas interview question

A pandas script runs out of memory or takes too long on a large file. How do you fix it?

Scenario Asked in Machine Learning Engineer · Data Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Load less and store it more compactly: read only needed columns (usecols), set efficient dtypes (categories for repeated strings, smaller numeric types), process in chunks or with filters, use vectorised operations instead of apply/loops, and switch to Parquet. If it still doesn't fit, use Polars, DuckDB or a distributed engine.

Keep reading with a membership

The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.

See plans and free trial Already a member? Sign in

More pandas questions

← All pandas questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake