Julia dataframe where a column is an array of arrays? -
i'm trying create table each row has time-series data associated particular test-case.
julia> df = dataframe(var1 = int64[], var2 = int64[], ts = array{array{int64, 1}, 1}) 0x3 dataframes.dataframe
i'm able create data frame. each var1
, var2
pair intended have associated time series.
i want generate data in loop , want append dataframe using push!
i've tried
julia> push!(df, [1, 2, [3,4,5]]) error: argumenterror: length of iterable not match dataframe column count. in push! @ /users/stro/.julia/v0.4/dataframes/src/dataframe/dataframe.jl:871
and
julia> push!(df, (1, 2, [3,4,5])) error: argumenterror: error adding [3,4,5] column :ts. possible type mis-match. in push! @ /users/stro/.julia/v0.4/dataframes/src/dataframe/dataframe.jl:883
what's best way go this? intended approach right path?
you've accidentally put type of vector in instead of actual vector. declaration work:
df = dataframe(var1 = int64[], var2 = int64[], ts = array{int64, 1}[])
note change array{array{int64, 1}, 1}
, type, array{int64, 1}[]
, actual vector type.
then things work:
julia> push!(df, (1, 2, [3,4,5])) julia> df 1x3 dataframes.dataframe │ row │ var1 │ var2 │ ts │ ┝━━━━━┿━━━━━━┿━━━━━━┿━━━━━━━━━┥ │ 1 │ 1 │ 2 │ [3,4,5] │
note other example, using [1, 2, [3,4,5]]
still not work. because quirk in julia's array syntax means comma ,
operator concatenation, in fact [1, 2, [3,4,5]]
means [1, 2, 3, 4, 5]
. behaviour weird , fixed in julia 0.5, preserved in 0.4 backwards compatibility.
Comments
Post a Comment