pandas to_csv is ~57.37× slower than polars write_csv for writing a CSV
The largest ratio on this site. Both write the same 400,000-row file to the same directory.
Result
| Run | pandas to_csv | polars write_csv | Ratio |
|---|---|---|---|
| Run 1 | 1293.36 | 22.94 | 56.38× |
| Run 2 | 1315.02 | 22.72 | 57.88× |
| Run 3 | 1294.45 | 22.56 | 57.37× |
Spread over 3 runs: pandas to_csv CV 0.9% / polars write_csv CV 0.8% / ratio CV 1.3%
The two calls
df.to_csv(out, index=False) df.write_csv(out) Conditions
Same frame in both libraries, written to a temp file on the same SSD.
Where this number does not apply
This includes formatting every value to text; it is not a statement about disk speed.
Reproduce
cd bench && python run.py --run 1 --out ../data/run1.json