polars.DataFrame.write_avro#

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

Write to Apache Avro file.

Parameters:
file

File path to which the file should be written.

compression{‘uncompressed’, ‘snappy’, ‘deflate’}

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.avro"
>>> df.write_avro(path)