gpt4 book ai didi

python - Pyarrow.lib.Schema 与 pyarrow.parquet.Schema

转载 作者:行者123 更新时间:2023-12-01 01:22:02 24 4
gpt4 key购买 nike

当我尝试加载多个分区的 Parquet 文件时,由于缺少用空值填充架构的数据,某些架构被无效推断。我认为在 pyarrow.parquet.ParquetDataset 中指定架构可以解决此问题,但我不知道如何构建正确的 pyarrow.parquet.Schema 类型的架构。一些示例代码:

import pyarrow as pa
import pa.parquet as pq
test_schema = pa.schema([pa.field('field1', pa.string()), pa.field('field2', pa.float64())])
paths = ['test_root/partition1/file1.parquet', 'test_root/partition2/file2.parquet']
dataset = pq.ParquetDataset(paths, schema=schema)

错误:

AttributeError: 'pyarrow.lib.Schema' object has no attribute 'to_arrow_schema'

但是我找不到任何有关如何构建 pyarrow.parquet.Schema 架构的文档( https://arrow.apache.org/docs/python/generated/pyarrow.parquet.ParquetDataset.html ),并且只制作了一个 pyarrow.lib.Schema ,它给出了上述错误。

最佳答案

尚无用于在 Python 中构建 Parquet 架构的 API。不过,您可以使用从特定文件中读取的文件(请参阅 pq.ParquetFile(...).schema )。

您能否在 ARROW JIRA 项目上提出一个问题,请求使用 Python 构建 Parquet 架构的功能?

https://issues.apache.org/jira

关于python - Pyarrow.lib.Schema 与 pyarrow.parquet.Schema,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53725691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com