polars_excel_writer
The polars_excel_writer
crate is a library for serializing Polars dataframes
to Excel Xlsx files.
The crate uses rust_xlsxwriter
to do the Excel serialization and is
typically 5x faster than Polars when exporting large dataframes to Excel.
It provides a primary interface PolarsXlsxWriter
which is a configurable
Excel serializer that resembles the interface options provided by the Polars
write_excel()
dataframe method.
The crate also provides a secondary ExcelWriter
interface which is a simpler
Excel serializer that implements the Polars SerWriter
trait to write a
dataframe to an Excel Xlsx file. However, unless you have existing code that
uses the SerWriter
trait you should use the PolarsXlsxWriter
interface.
Example
An example of writing a Polar Rust dataframe to an Excel file using the
PolarsXlsxWriter
interface.
use *;
use *;
use PolarsXlsxWriter;
Output file:
Performance
The table below shows the performance of writing a dataframe using Python
Polars, Python Pandas and PolarsXlsxWriter
.
Test Case | Time (s) | Relative (%) |
---|---|---|
Polars |
6.49 | 100% |
Pandas |
10.92 | 168% |
polars_excel_writer |
1.22 | 19% |
polars_excel_writer + zlib |
1.08 | 17% |
See the Performance section of the docs for more detail.