polars.DataFrame.write_ipc#

DataFrame.write_ipc(
file: None,
compression: IpcCompression = 'uncompressed',
) BytesIO[source]#
DataFrame.write_ipc(
file: BinaryIO | BytesIO | str | Path,
compression: IpcCompression = 'uncompressed',
) None

Write to Arrow IPC binary stream or Feather file.

Parameters:
file

Path to which the IPC data should be written. If set to None, the output is returned as a BytesIO object.

compression{‘uncompressed’, ‘lz4’, ‘zstd’}

Compression method. Defaults to “uncompressed”.

Examples

>>> import pathlib
>>>
>>> df = pl.DataFrame(
...     {
...         "foo": [1, 2, 3, 4, 5],
...         "bar": [6, 7, 8, 9, 10],
...         "ham": ["a", "b", "c", "d", "e"],
...     }
... )
>>> path: pathlib.Path = dirpath / "new_file.arrow"
>>> df.write_ipc(path)