【问题标题】:vaex Object dtype dtype('O') has no native HDF5 equivalentvaex Object dtype dtype('O') 没有本机 HDF5 等效项
【发布时间】:2020-04-28 15:42:20
【问题描述】:

我使用 vaex.from_csv() 将 csv 转换为 hdf5 。

import vaex
vaex.from_csv("/Users/xxxx/development/vaex/dataAN/testdata1.csv", convert=True)

获取

IPython/core/interactiveshell.py:3331: DtypeWarning: Columns (53,55) have mixed types.Specify dtype option on import or set low_memory=False.
  exec(code_obj, self.user_global_ns, self.user_ns)
ERROR:MainThread:root:error creating dataset for 'EXT_SUB_ACC', with type dtype('O') 
Traceback (most recent call last):
  File "/Users/xxxx/development/vaex/install/vaex/packages/vaex-core/vaex/hdf5/export.py", line 201, in export_hdf5
    array = h5column_output.require_dataset('data', shape=shape, dtype=dtype.newbyteorder(byteorder))
  File "/Users/xxxx/.conda/envs/vaex/lib/python3.7/site-packages/h5py/_hl/group.py", line 191, in require_dataset
    return self.create_dataset(name, *(shape, dtype), **kwds)
  File "/Users/xxxx/.conda/envs/vaex/lib/python3.7/site-packages/h5py/_hl/group.py", line 136, in create_dataset
    dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds)
  File "/Users/xxxx/.conda/envs/vaex/lib/python3.7/site-packages/h5py/_hl/dataset.py", line 119, in make_new_dset
    tid = h5t.py_create(dtype, logical=1)
  File "h5py/h5t.pyx", line 1634, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1656, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1711, in h5py.h5t.py_create
TypeError: Object dtype dtype('O') has no native HDF5 equivalent

这些错误是什么意思?

【问题讨论】:

  • 请添加导致这些错误的代码。特别是,请展示从vaex.from_csv() 转换数据然后写入HDF5 的步骤。

标签: python hdf5 import-from-csv dtype vaex


【解决方案1】:

这里给出一个提示:

IPython/core/interactiveshell.py:3331: DtypeWarning: Columns (53,55) have mixed types.Specify dtype option on import or set low_memory=False.

Pandas 找不到通用类型,因此使用 dtype=object,它不能保存到 hdf5(它没有本地机器表示)。如果您强制使用 dtype,则通过将该参数传递给 from_csv,vaex 会将其传递给 pandas。

【讨论】:

    猜你喜欢
    • 2019-04-20
    • 2013-04-10
    • 1970-01-01
    • 2020-09-15
    • 2019-09-03
    • 2018-07-04
    • 2020-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多