Hub documentation

文件格式

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

文件格式

Polars 在从 Hugging Face 读取数据时支持以下文件格式:

以下示例仅展示默认设置。请使用上方的链接在 API 参考指南中查看所有可用参数。

Parquet

Parquet 是首选的文件格式,因为它在文件内部存储了包含类型信息的模式(schema)。这避免了解析过程中的任何歧义,并加快了读取速度。要在 Polars 中读取 Parquet 文件,请使用 read_parquet 函数:

pl.read_parquet("hf://datasets/roneneldan/TinyStories/data/train-00000-of-00004-2d5a1467fff1081b.parquet")

CSV

read_csv 函数可用于读取 CSV 文件:

pl.read_csv("hf://datasets/lhoestq/demo1/data/train.csv")

JSON

Polars 支持读取以换行符分隔的 JSON——也称为 json lines——使用 read_ndjson 函数:

pl.read_ndjson("hf://datasets/proj-persona/PersonaHub/persona.jsonl")
Update on GitHub