← All notes

Load a Spark DataFrame into Hugging Face Datasets

Short answer

Use Dataset.from_spark(df). Spark workers write the data to a cache directory as Arrow files and the Dataset loads from there, so large data does not pass through the driver. For files already on disk or on the Hub, load_dataset reads CSV, JSON and Parquet directly. [S1][S2]

from datasets import Dataset
ds = Dataset.from_spark(spark_df)

Claims

Sources

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 (datasets docs), Use with Spark · Hugging Face, Apache-2.0 (huggingface/datasets docs); Hugging Face (datasets docs), Load · Hugging Face, Apache-2.0 (huggingface/datasets docs).

Cite this

Permanent ID: iil:note:txcfb69m

iinventedlight. 2026. "Load a Spark DataFrame into Hugging Face Datasets." iinventedlight Library, iil:note:txcfb69m, version of 2026-11-04. https://iinventedlight.com/library/notes/hf-datasets-spark/. License: CC-BY-4.0.

@misc{iil_note_txcfb69m,
  author = {{iinventedlight}},
  title = {{Load a Spark DataFrame into Hugging Face Datasets}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/hf-datasets-spark/},
  note = {Permanent ID iil:note:txcfb69m. License: CC-BY-4.0.},
}

Markdown

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-spark.md.