Reputation: 397
I have an 183 elements array that I would like to transform into a one colum dataframe. The array looks df
like as follows:
183-element Array{Array{Float64,2},1}:
[76.1042 50.0618 … -1.72986 -1.716]
[95.2629 84.1194 … -1.7071 -1.69628]
[67.404 40.0616 … -6.01294 -5.47409]
[66.0865 44.2233 … -4.57463 -4.19918]
[45.1631 10.8539 … -1.73326 -1.71894]
[98.5844 94.8746 … -4.57998 -4.20398]
[50.1387 25.6277 … -1.68957 -1.68109]
[45.608 15.6854 … -1.70545 -1.69486]
[40.515 7.37472 … -4.01657 -3.70847]
[42.3056 11.6015 … -3.12091 -2.9249]
[12.3731 -10.2234 … -3.41232 -3.17932]
[12.6298 -9.61076 … -1.68518 -1.67729]
[13.0059 -8.60469 … -2.96391 -2.78804]
⋮
[-112.757 -85.998 … -20.0213 -20.019]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-109.492 -84.4215 … -20.013 -20.013]
[-113.341 -28.5849 … -20.013 -20.013]
The idea is to create a dataframe with one column which is then filled in with the values contained in the 183 element array. Ultimately, I want to export the created dataframe into a csv file.
I have tried something like that but it does not work:
df_output=DataFrame(x1=Float64[])
for i= 1:length(df)
test=convert(DataFrame, df[i]')
push!(df_output, test)
end
Anyone can help me with that? Thanks.
Upvotes: 0
Views: 106
Reputation: 397
Thanks to @Dan Getz, this command line below does the job!
df_output = DataFrame(x1=mapreduce(vec, vcat, df))
Upvotes: 1