【问题标题】:Write large pandas dataframe as parquet with pyarrow用 pyarrow 将大熊猫数据框写成镶木地板
【发布时间】:2020-04-20 02:03:02
【问题描述】:

我正在尝试编写一个大熊猫数据框(形状 4247x10)

没什么特别的,只是使用下一个代码:

df_base = read_from_google_storage()
df_base.to_parquet(courses.CORE_PATH,
                   engine='pyarrow',
                   compression='gzip',
                   partition_cols=None)

我尝试使用不同的压缩方式、不同的 partition_cols 都失败了,但还是失败了。

我提到它适用于小型数据帧 (1000x10

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

我正在使用的库:

pandas==0.25.3
pyarrow==0.15.1

【问题讨论】:

  • 你能在本地写入或读取相同的 pandas 数据帧吗?
  • @NibrasHaider 在本地,它适用于 fastparquet,但对于 pyarrow 会出现同样的错误。
  • 似乎谷歌存储无论如何都没有影响错误。我用 pyarrow 用另一个数据集 1500x7 在本地重现了错误

标签: python pandas pyarrow


【解决方案1】:

问题可能与此有关:https://issues.apache.org/jira/browse/PARQUET-1345 但我不确定。

这是我找到的解决方法:

from pyarrow import Table
from pyarrow import parquet as pq


df_base = pd.read_csv('big_df.csv')

table = Table.from_pandas(df_base, nthreads=1)
print(table.columns)
print(table.num_rows)
pq.write_table(table, courses.CORE_PATH, compression='GZIP')

我不确定它到底为什么会失败,但设置 nthreads=1 有助于避免 SIGSEGV(分段错误)

【讨论】:

  • 如果您有可重现的示例,您能否向 Apache Arrow JIRA 或 Parquet JIRA 报告?谢谢
猜你喜欢
  • 2020-01-16
  • 2022-11-03
  • 2017-04-25
  • 2021-08-27
  • 2021-10-28
  • 2018-04-21
  • 1970-01-01
  • 2017-12-16
  • 2021-02-28
相关资源
最近更新 更多