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

Changed in version 1.1: The future parameter was renamed compat_level.

Parameters:
compat_level

Compatibility level to use when exporting Polars data structures. The default compatibility level is recommended for most users. Use pl.CompatLevel.oldest() for the most compatible level. pl.CompatLevel.newest() uses the highest supported compatibility level, but is considered unstable and may change without it being considered a breaking change.

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"]]