right now I am trying to save a Dataframe into a file and read it again. For this I used the CSV package. My dataframe has two columns where each entry is a vector. Here is an small example:
using DataFrames
using CSV
x = Vector{Array{Float64, 1}}()
y = Vector{Array{Float64, 1}}()
push!(x, [1,2,3])
push!(x, [4,5,6])
push!(y, [100,101,102])
push!(y, [103,104,105])
df = DataFrame(x=x, y=y)
CSV.write("export_df.csv", df)
test = CSV.read("export_df.csv")
println(typeof(df["x"][1]))
println(typeof(test["x"][1]))
The first output returns an Array{Float64,1} type, while type of test[“x”][1] returns a string. Can someone give me an advise how to fix this, such that I get an Array again?
cc @quinnj on this. Reading through the docs CSV.File (which will replace CSV.read eventually), it looks like the type keyword you would use to specify types only works for small concrete types like Float64, Int etc.
I also think it’s tough to parse the results from test into an array.
My recommendation is to use DataFrame’s flatten function to save the data in “long” format and then use combine to put the result back into vectors after you read it in.