Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Polars · Function

pl.read_ipc

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.

How it works

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.

Syntax

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

Parameters

NameTypeDescription
sourcestr | Path | IO[bytes] | bytesPath to a file or a file-like object, such as an open file handler or BytesIO instance.
columnslist[int] | list[str] | NoneColumns to select by zero-based index or name.
n_rowsint | NoneStop reading after this many rows; only valid with the native reader.
use_pyarrowboolChoose PyArrow instead of the native Rust reader.
storage_optionsStorageOptionsDict | NoneOptions for fsspec.open or a storage connection.
row_index_namestr | NoneName of a row-index column to insert first; None creates no index.
row_index_offsetintStarting value for the row index; used only when row_index_name is set.

Returns

DataFrame

Key points

  • The function eagerly loads Arrow IPC or Feather v2 data into a Polars DataFrame.
  • Column projection can use zero-based integer positions or column names.
  • use_pyarrow selects between the PyArrow implementation and Polars' native Rust reader.
  • n_rows can cap the number of rows read when the native reader is used.
  • A named row index is inserted before the other DataFrame columns.
  • storage_options forwards filesystem or connection settings for supported remote sources.

Common mistakes

  • n_rows is unavailable when the PyArrow reader is selected.
  • row_index_offset must be zero or greater.
  • row_index_offset has no effect unless a row-index column name is supplied.
  • Do not convert the eagerly materialized result to lazy mode when you need reader optimizations; use a lazy IPC scan instead.

Example: Read selected IPC columns

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.

When to use it

Read IPC files

Load a local Feather v2 or Arrow IPC file into a DataFrame for eager analysis.

Project columns during ingestion

Reduce input width by loading only selected columns.

Access cloud-backed IPC data

Read supported remote filesystems with credentials or connection settings.

Create a row index

Add stable positional identifiers while importing records.

Interview questions

QWhat does read_ipc return and what input format does it read?

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.

QHow do columns and n_rows affect reading?

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.

QHow does row-index creation work?

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_schema
  • polars.read_ipc_stream
  • polars.scan_ipc
  • polars.DataFrame.write_ipc
  • polars.DataFrame.write_ipc_stream

Source: polars.read_ipc — Polars documentation. Checked 2026-10-15.