I created a Vector of Vectors, named all_arrays in Julia in this way for a specific purpose:
using DataFrames
using StatsBase
list_of_numbers = 1:17
all_arrays = [zeros(Float64, (17,)) for i in 1:1000]
round = 1
while round != 1001
random_array = StatsBase.sample(1:17 , length(list_of_numbers))
random_array = random_array/sum(random_array)
if (0.0 in random_array) || (random_array in all_arrays)
continue
end
all_arrays[round] = random_array
round += 1
println(round)
end
The dimension of all_arrays is:
julia> size(all_arrays)
(1000,)
Then I want to convert all_arrays into a DataFrame with 1000*17 dimensions (Note that each vector in the all_arrays is a (17,) shape Vector). I tried This way:
df = DataFrames.DataFrame(zeros(1000,17) , :auto)
for idx in 1:length(all_arrays)
df[idx , :] = all_arrays[idx]
end
But I'm looking for a straightforward way for this instead of a for loop and a prebuilt DataFrame! Is there any?