gpt4 book ai didi

python - 在Python中获取 Parquet 文件的架构

转载 作者:行者123 更新时间:2023-12-03 15:25:15 27 4
gpt4 key购买 nike

是否有可用于仅获取 Parquet 文件的架构的python库?
当前,我们正在将 Parquet 文件加载到Spark中的数据框中,并从该数据框中获取架构以显示在应用程序的某些UI中。但是初始化spark-context并加载数据框架并从数据框架获取架构是耗时的事件。因此,正在寻找一种仅获取模式的替代方法。

最佳答案

通过使用pyarrow(https://github.com/apache/arrow/)支持此功能。

from pyarrow.parquet import ParquetFile
# Source is either the filename or an Arrow file handle (which could be on HDFS)
ParquetFile(source).metadata

注意:我们仅在昨天才合并了此代码,因此您需要从源代码构建它,请参阅 https://github.com/apache/arrow/commit/f44b6a3b91a15461804dd7877840a557caa52e4e

关于python - 在Python中获取 Parquet 文件的架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41567081/

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