Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

transfer a data frame from python to julia

I have a Dataframe of 250 columns and 4562 rows. I want to use it in Julialang. I have tried using HDF5 to transfer the data but it gives an error reading the file. code:

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)

This is the error I got:

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"]

Any help is greatly appreciated!!

like image 850
yash bhargava Avatar asked Mar 24 '26 13:03

yash bhargava


1 Answers

For this I always use the feather format.

E.g. in python

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

and then in Julia

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

You can load/save also from R.

like image 124
user73898 Avatar answered Mar 26 '26 04:03

user73898



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!