将数据帧从python传输到julia

时间:2018-06-25 08:53:01

标签: python dataframe julia hdf5

我有一个250列和4562行的数据框。我想在Julialang中使用它。我尝试使用HDF5传输数据,但读取文件时出现错误。 代码:

using HDF5
using DataFrames  
data=h5open("Database.h5")
typeof(data)
println("names \n",names(data))
println("\n dump")
println(names(data))
m=data["nse"]
println(names(m))
jj=m["table"]
s=read(jj)

这是我得到的错误:

HDF5-DIAG: Error detected in HDF5 (1.10.2) thread 0:
  #000: H5O.c line 120 in H5Oopen(): unable to open object
    major: Object header
    minor: Can't open object
  #001: H5Oint.c line 553 in H5O_open_name(): unable to open object
    major: Object header
    minor: Can't open object
  #002: H5Oint.c line 589 in H5O_open_by_loc(): unable to determine object class
    major: Object header
    minor: Can't get value
  #003: H5Oint.c line 1575 in H5O_obj_class(): unable to load object header
    major: Object header
    minor: Unable to protect metadata
  #004: H5Oint.c line 889 in H5O_protect(): unable to load object header
    major: Object header
    minor: Unable to protect metadata
  #005: H5AC.c line 1763 in H5AC_protect(): H5C_protect() failed
    major: Object cache
    minor: Unable to protect metadata
  #006: H5C.c line 2565 in H5C_protect(): can't load entry
    major: Object cache
    minor: Unable to load metadata into cache
  #007: H5C.c line 6733 in H5C_load_entry(): invalid len with respect to EOA
    major: Object cache
    minor: Bad value
  #008: H5C.c line 6657 in H5C__verify_len_eoa(): len not positive after adjustment for EOA
    major: Object cache
    minor: Bad value
String["_i_table", "table"]

非常感谢您的帮助!

1 个答案:

答案 0 :(得分:5)

为此,我总是使用feather format

例如在python中

import feather
feather.write_dataframe(df, "path/to/file.feather")

然后在朱莉娅

using DataFrames, Feather
df = Feather.read("path/to/file.feather")

您也可以从R中加载/保存。