将数据帧从 python 传输到 julia

transfer a data frame from python to julia

我有一个 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"]

非常感谢任何帮助!!

为此我总是使用 feather format

例如在 python

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

然后在 Julia

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

您也可以 load/save 来自 R。