I would like to do something like this:
using DataFrames dflong = DataFrame() for i = 1:3 df = DataFrame(a = rand(i)) vcat(dflong, df) end
I understand that this doesn’t work for two reasons:
dflongcannot be modified inside the local
- Even if it could,
dfhave a different number of columns.
I have devised a solution that works, but seems very ugly, inelegant, and perhaps inefficient:
using DataFrames dflong = DataFrame() first = true for i = 1:3 df = DataFrame(a = rand(i)) global dflong global first if first dflong = similar(df, 0) first = false else dflong = vcat(dflong, df) end end
Can you suggest a better way to do this?
I am new to Julia so probably just not getting something basic here about the proper way to adapt to for loops with local scope.