I want to add columns to a dataframe iteratively in a loop and assign them a name. The code below seems to add one column to the dataframe containing value of p at the last iteration and name of the column appears as colname instead of Test10.
Using DataFrames
df = DataFrame()
for i = 1:10
p = rand(3)
colname = "Test$i"
df[!,:colname] = p
end
How to fix this so that the dataframe contains values of p for all iterations (i.e. one column for each iteration) along with column names (e.g. Test1,Test2,…Test10)?