Read a column subset
A Feather file contains many fields but an analysis needs only a few.
Pandas · Function
Loads a Feather-format file or file-like object into a pandas DataFrame. It supports column selection, threaded reading, storage options, and configurable dtype backends.
Pass a filesystem path, URL, or binary file-like object to load Feather data into a DataFrame. You can restrict columns, enable or disable threaded reading, provide connection options for remote locations, and choose the resulting dtype backend.
pandas.read_feather(path, columns=None, use_threads=True, storage_options=None, dtype_backend=<no_default>)| Name | Type | Description |
|---|---|---|
path | str, path object, or file-like object | String, path-like object, or binary file-like object; URLs may use documented remote schemes. |
columns | sequence, default None | Columns to load; when omitted, every column is read. |
use_threads | bool, default True | Whether to parallelize reading with multiple threads. |
storage_options | dict, optional | Additional options for the relevant storage connection. |
dtype_backend | {'numpy_nullable', 'pyarrow'}, default no_default | Result dtype backend; documented choices are numpy_nullable and pyarrow. |
DataFrame object stored in the file.
import pandas as pd
# Requires pyarrow and a Feather file at this path.
df = pd.read_feather("data.feather", columns=["user_id", "score"])
print(df)Reads only the selected columns from a Feather file into a pandas DataFrame.
A Feather file contains many fields but an analysis needs only a few.
A dataset is stored in an object store or accessible through a URL.
A pipeline requires a particular nullable or PyArrow dtype representation.
It loads a Feather-format object and returns the stored data as a DataFrame. The path may be a string, path-like object, or binary file-like object.
Follow-up: What remote locations can path represent? It can be a URL using schemes such as http, ftp, s3, gs, or file, with the documented file-URL host requirement.
columns controls projection: when omitted, every column is read; when supplied, only the requested sequence is read. use_threads controls whether reading is parallelized with multiple threads and defaults to True.
Follow-up: Why pass columns in a large-file workflow? Selecting only needed columns can reduce the data that must be read and materialized.
dtype_backend selects the dtype representation for the resulting DataFrame. The documented choices are numpy_nullable and pyarrow; without it, pandas does not use nullable data types by default.
Follow-up: What should be considered before choosing pyarrow? The option changes the resulting dtype backend and is marked experimental in the documentation.
pandas.DataFrame.to_featherpandas.read_parquetpandas.read_csv