polars.DataFrame.write_ipc#

DataFrame.write_ipc(
file: str | Path | IO[bytes] | None,
compression: IpcCompression = 'uncompressed',
*,
future: bool = False,
) BytesIO | None[source]#

Write to Arrow IPC binary stream or Feather file.

See “File or Random Access format” in https://arrow.apache.org/docs/python/ipc.html.

Parameters:
file

Path or writable file-like object to which the IPC data will be written. If set to None, the output is returned as a BytesIO object.

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

Compression method. Defaults to “uncompressed”.

future

Setting this to True will write Polars’ internal data structures that might not be available by other Arrow implementations.

Warning

This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.

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)