使用Vaex读取Parquet文件

3

我正在尝试使用Vaex从Parquet文件中读取一些数据到Python中。

这是使用vaex.open函数获得的输出结果。

>>> import vaex
>>> trade = vaex.open('trade.parquet')
>>> trade
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 3703, in __repr__
    return self._head_and_tail_table(format='plain')
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 3464, in _head_and_tail_table
    return self._as_table(0, n, N - n, N, format=format)
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 3599, in _as_table
    parts = table_part(i1, i2, parts)
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 3573, in table_part
    df = self[k1:k2]
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 4626, in __getitem__
    df = self.trim()
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 3859, in trim
    df = self if inplace else self.copy()
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 5036, in copy
    df.add_column(name, column, dtype=self._dtypes_override.get(name))
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 6053, in add_column
    super(DataFrameArrays, self).add_column(name, data, dtype=dtype)
  File "/home/userman/.local/lib/python3.6/site-packages/vaex/dataframe.py", line 2942, in add_column
    raise ValueError("array is of length %s, while the length of the DataFrame is %s" % (len(ar), self.length_original()))
ValueError: array is of length 1048576, while the length of the DataFrame is 34421587

数据框架的长度是正确的,但我不理解 1048576 与什么相关。我找到了一个有关读取hdf5文件的 之前的答案 ,但它似乎与我的问题无关。该数据最初从csv文件中读取,然后使用pyarrow导出为parquet格式。
有人能详细说明问题是什么以及如何解决吗?

也许这个在 Github 上的开放问题也导致了你的问题:https://github.com/vaexio/vaex/issues/834 - asmaier
1个回答

0

我曾经遇到过同样的问题,因此我猜测您正在使用vaex 3.x。请尝试在一个全新的虚拟环境中安装最新的alpha 4.0.0a13版本。

pip install vaex==4.0.0a13

更新

截至2021年3月9日,vaex 4已经发布并标记为pypi中的默认版本,因此不再需要指定版本号。

pip install vaex


vaex 的新版本已发布 pip install vaex==4,其中这些问题得到了更好的解决。 - Joco

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接