Read IPC files
Load a local Feather v2 or Arrow IPC file into a DataFrame for eager analysis.
Polars · Function
Reads an Arrow IPC (Feather v2) file or byte stream into an eager Polars DataFrame, with optional column projection, row limiting, PyArrow selection, storage options, and row indexing.
The function eagerly reads an Arrow IPC (Feather v2) file or byte stream into a DataFrame. You can project columns, limit rows with the native reader, configure cloud/filesystem access, and optionally add a nonnegative row-index column.
polars.read_ipc(source: str | Path | IO[bytes] | bytes, *, columns: list[int] | list[str] | None = None, n_rows: int | None = None, use_pyarrow: bool = False, storage_options: StorageOptionsDict | None = None, row_index_name: str | None = None, row_index_offset: int = 0) → DataFrame| Name | Type | Description |
|---|---|---|
source | str | Path | IO[bytes] | bytes | Path to a file or a file-like object, such as an open file handler or BytesIO instance. |
columns | list[int] | list[str] | None | Columns to select by zero-based index or name. |
n_rows | int | None | Stop reading after this many rows; only valid with the native reader. |
use_pyarrow | bool | Choose PyArrow instead of the native Rust reader. |
storage_options | StorageOptionsDict | None | Options for fsspec.open or a storage connection. |
row_index_name | str | None | Name of a row-index column to insert first; None creates no index. |
row_index_offset | int | Starting value for the row index; used only when row_index_name is set. |
DataFrame
import polars as pl
# Requires an Arrow IPC/Feather v2 file named "data.arrow".
df = pl.read_ipc("data.arrow", columns=["user_id", "score"], n_rows=100)
print(df)Reads selected columns and stops after at most 100 rows from a local Arrow IPC file.
Load a local Feather v2 or Arrow IPC file into a DataFrame for eager analysis.
Reduce input width by loading only selected columns.
Read supported remote filesystems with credentials or connection settings.
Add stable positional identifiers while importing records.
It reads Arrow IPC, also known as Feather v2, data into an eager Polars DataFrame. The source may be a path, byte buffer, or file-like object.
Follow-up: How would you preserve laziness? Use the documented scan_ipc function and collect only after building the lazy query.
columns accepts either zero-based integer positions or column names, allowing projection during reading. n_rows limits how many rows are read, but only with the native Rust reader.
Follow-up: What should you do if PyArrow is required but row limiting is also required? Read with PyArrow and apply the row limit after loading, because n_rows is not supported in that mode.
row_index_name adds an index column as the first DataFrame column. row_index_offset controls its starting value, is nonnegative, and is ignored unless row_index_name is set.
Follow-up: How can cloud credentials or connection settings be passed? Supply storage_options containing options understood by fsspec.open or the relevant storage connection.
polars.read_ipc_schemapolars.read_ipc_streampolars.scan_ipcpolars.DataFrame.write_ipcpolars.DataFrame.write_ipc_stream