Question presented to candidate: "Our team does most of its data work in pandas. People keep saying we should move to Polars. What actually differs between the two, and how would you decide whether a given project should switch?"
What a strong answer should cover:
- Engine: Polars is a Rust, multi-threaded, columnar (Apache Arrow memory) DataFrame library with an expression API and a lazy query optimizer; pandas is eager, mostly NumPy-backed, single-threaded for most operations
- API model: Polars has no row index and no in-place mutation; pandas has the index (label alignment), a huge API and the widest ecosystem (scikit-learn, statsmodels, plotting, notebooks)
- pandas 3.0 (January 2026) narrowed some gaps: Copy-on-Write is the only mode, text columns default to a
strdtype, andpd.colexpressions exist, but execution is still eager - When switching pays: large files (GBs), heavy group-by / join pipelines, ETL jobs where run time and memory cost money, new code without deep pandas dependencies; when it does not: small data, notebooks tied to pandas-only libraries, code that leans on the index
- Migration strategy: switch at the pipeline boundary, convert with
to_pandas()/from_pandasfor the last step, benchmark on your real data, check Polars version changes (1.0 in July 2024; 2.0 makes streaming the default engine)
Clarifying questions expected:
- How big is the data, and is the pain run time, memory, or code complexity?
- Which downstream libraries consume the DataFrames, and do they require pandas?
- Is this a new pipeline or a large existing codebase with tests?
Code / implementation expected: Optional β the same filter / group-by in both libraries, or a short argument with numbers from a benchmark on your own data.