As the title says, how can I programatically construct a ComponentArray or NamedTuple from a vector of strings (or symbols) and a vector of numbers?
from this
n = ["a", "b", "c"]
x = [1, 2, 3]
I want to get this
ca = ComponentArray(a = 1, b = 2, c = 3)
or this
nt = (a = 1, b = 2, c = 3)
The application I have in mind is to construct a ComponentArray or NamedTuple from a DataFrame:
df = DataFrame(a = 1, b = 2, c = 3)
(I think the way for constructing either ComponentArrays or NamedTuples would be the same)
Convert any table (eg DataFrame) to a namedtuple-of-arrays: Tables.columntable(...); to an array-of-namedtuples: Tables.rowtable(...). These may be more helpful for your specific usecase.