Hub 文档

文件格式

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

文件格式

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

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

Parquet

Parquet 是首选的文件格式,因为它在文件中存储带有类型信息的模式。这避免了任何解析歧义并加快了读取速度。要在 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")
< > 在 GitHub 上更新