使用不同长度的数组条目保存DataFrame

时间:2018-06-06 17:59:19

标签: dataframe julia

julia> x = [rand(k) for k in 1:10];

julia> d = DataFrame(x=Vector{Float64}[]);

julia> for k in 1:10
           push!(d, [x[k]])
       end

julia> d
10×1 DataFrames.DataFrame
│ Row │ x                                                                                                  │
├─────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 1   │ [0.912215]                                                                                         │
│ 2   │ [0.0865126, 0.260076]                                                                              │
│ 3   │ [0.61766, 0.969529, 0.177093]                                                                      │
│ 4   │ [0.927896, 0.521724, 0.669713, 0.148345]                                                           │
│ 5   │ [0.779086, 0.715808, 0.943805, 0.197353, 0.716311]                                                 │
│ 6   │ [0.0932849, 0.660737, 0.547138, 0.00146499, 0.0726306, 0.84183]                                    │
│ 7   │ [0.246593, 0.131446, 0.378437, 0.584403, 0.777732, 0.670934, 0.618792]                             │
│ 8   │ [0.00339141, 0.704945, 0.0235316, 0.0806565, 0.332005, 0.304394, 0.157108, 0.12613]                │
│ 9   │ [0.401086, 0.802521, 0.661974, 0.369114, 0.331184, 0.341598, 0.138835, 0.673759, 0.599687]         │
│ 10  │ [0.615559, 0.445397, 0.104951, 0.182031, 0.844579, 0.613385, 0.887714, 0.139976, 0.991951, 0.2642] │

julia> @save "test.jld" d
ERROR: DimensionMismatch("mismatch in dimension 1 (expected 1 got 2)")

如何保存此DataFrame(最好使用JLD)?

0 个答案:

没有答案