Pyarrow将嵌套数组写入实木复合地板

时间:2019-03-04 14:40:59

标签: python parquet pyarrow

我想编写一个镶木地板文件,其中包含一些具有一维数组数据的普通列和一些具有嵌套结构(即二维数组)的列。

我尝试了以下方法:

import pyarrow as pa
import pyarrow.parquet as pq
import numpy as np

array1 = np.array([0, 1, 2], dtype=np.uint8)
array2 = np.array([[0,1,2], [3, 4, 5]], dtype=np.uint8).T

t1 = pa.uint8()
t2 = pa.list_(pa.uint8())

fields = [
    pa.field('a1', t1),
    pa.field('a2', t2)
]

myschema = pa.schema(fields)

mytable = pa.Table.from_arrays([
    pa.array(array1, type=t1),
    pa.array([array2[:,0], array2[:,1]], type=t2)],
    schema=myschema)

pq.write_table(mytable, 'example.parquet')

表创建按预期工作。最后一行是问题所在。这会导致解释的Python崩溃。

在Windows Python 3.6.4 64位上,我得到了错误代码: 编辑:,使用pyarrow 0.11.1

Process finished with exit code -1073741819 (0xC0000005)

我还尝试在Windows Linux(WSL)中使用单独安装的Python 3.6.5 64位进行尝试,并且得到: 编辑:使用pyarrow 0.12.1

Segmentation fault (core dumped)

我已经看到this post建议重新安装Python,但是由于到目前为止我尝试了两种不同的安装方式,所以我认为这样做没有帮助。

我在PyArrow文档中看不到任何建议将嵌套数组写入Parquet的工作,我知道fastparquet中有issues with this

0 个答案:

没有答案