polars.DataFrame.to_arrow#

DataFrame.to_arrow(
*,
compat_level: CompatLevel | None = None,
) Table[source]#

Collect the underlying arrow arrays in an Arrow Table.

This operation is mostly zero copy.

Data types that do copy:
  • CategoricalType

Parameters:
compat_level

Use a specific compatibility level when exporting Polars’ internal data structures.

Examples

>>> df = pl.DataFrame(
...     {"foo": [1, 2, 3, 4, 5, 6], "bar": ["a", "b", "c", "d", "e", "f"]}
... )
>>> df.to_arrow()
pyarrow.Table
foo: int64
bar: large_string
----
foo: [[1,2,3,4,5,6]]
bar: [["a","b","c","d","e","f"]]