Hugging Face Datasets and Apache Arrow
Answer:
from datasets import load_dataset
ds = load_dataset("imdb", split="train")
ds = ds.with_format("arrow")
for table in ds.iter(batch_size=1000): # pyarrow.Table batches
print(table.num_rows)
import pyarrow.compute as pc
ds = ds.map(lambda t: t.append_column("len", pc.utf8_length(t["text"])), batched=True)
Why Arrow
- Zero-copy reads: almost no serialization overhead.
- Language-agnostic: the same data works from many languages.
- This is possible because the Arrow data is actually memory-mapped from disk, and not loaded in memory. (S2)
Claims
- id: C1 claim: You can set the dataset format to pyarrow with with_format. source: S1 evidence: "you can set the format of the dataset to pyarrow using Dataset.with_format():"
- id: C2 claim: Datasets uses Arrow for its local caching system. source: S2 evidence: "Datasets uses Arrow for its local caching system."
- id: C3 claim: Arrow stores data in a columnar memory layout. source: S2 evidence: "It is a specific data format that stores data in a columnar memory layout."
- id: C4 claim: Arrow's format allows zero-copy reads. source: S2 evidence: "Arrow’s standard format allows zero-copy reads which removes virtually all serialization overhead."
- id: C5 claim: Arrow data is memory-mapped from disk, not loaded in memory. source: S2 evidence: "the Arrow data is actually memory-mapped from disk, and not loaded in memory."
Sources
- [S1] Use with PyArrow · Hugging Face. Hugging Face docs. https://huggingface.co/docs/datasets/use_with_pyarrow . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-04.
- [S2] Datasets 🤝 Arrow · Hugging Face. Hugging Face docs. https://huggingface.co/docs/datasets/about_arrow . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs, Use with PyArrow · Hugging Face, Apache-2.0 (huggingface docs repos); Hugging Face docs, Datasets 🤝 Arrow · Hugging Face, Apache-2.0 (huggingface docs repos).
Cite this
iinventedlight. 2026. "Hugging Face Datasets and Apache Arrow." iinventedlight Library, iil:note:61ehd4gd, version of 2026-11-04. https://iinventedlight.com/library/notes/hf-datasets-pyarrow/. License: CC-BY-4.0.
@misc{iil_note_61ehd4gd,
author = {{iinventedlight}},
title = {{Hugging Face Datasets and Apache Arrow}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/hf-datasets-pyarrow/},
note = {Permanent ID iil:note:61ehd4gd. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/hf-datasets-pyarrow.md.