julia DataFrame column names -
i want name column names of blank datframe.
i having trouble (re)naming multiple columns of dataframe in v0.6.
i've tried generating names:
df = dataframe() nms = [":x$i" in 1:2] df[nms[1] = rand(10)] df[nms[2] = rand(10)]
but symbol requirement names not working $
macro. have fix?
df = dataframe() nms = [symbol("x$i") in 1:2] df[nms[1]] = rand(10) df[nms[2]] = rand(10)
works , similar code in question. key index dataframes julia symbols , not strings.
a more compact way make df
using dataframe constructor takes columns parameters. there one, parameters named parameters, need splat (i.e. ...
) dict insert parameters. dict needs generated programmatically. maintain specific order of columns in dict, need ordereddict. outcome is:
using dataframes, datastructures df = dataframe(;ordereddict((symbol("x$i")=>rand(10) i=1:3)...)...)
Comments
Post a Comment