Closed lazarusA closed 1 year ago
You can construct a NamedTuple from your list of variables and list of variable names and then splat this inside the Dataset call.
keylist = (:a, :b,:c)
varlist = (YAXArray(rand(10)), YAXArray(rand(10)), YAXArray(rand(10)))
julia> YAXArrays.Dataset(;(;zip(keylist,varlist)...)...)
YAXArray Dataset
Shared Axes:
Dim{:Dim_1} Sampled{Int64} Base.OneTo(10) ForwardOrdered Regular Points
Variables:
a, b, c,
Thanks, for one variable would be like this:
keylist = (:a, )
varlist = (YAXArray(rand(10)),)
YAXArrays.Dataset(;(;zip(keylist,varlist)...)...)
it works, but its really cumbersome, maybe having an enhancement to make this more user friendly would be a good, @meggart .
You can shorten that to the following, which is still obscure but a bit better:
julia> YAXArrays.Dataset(; (keylist .=> varlist)...)
YAXArray Dataset
Shared Axes:
Dim{:Dim_1} Sampled{Int64} Base.OneTo(10) ForwardOrdered Regular Points
Variables:
a,
nice! final solution
YAXArrays.Dataset(; (:a => YAXArray(rand(10)),)...)
currently we do
and the variable name is
z
, but is there a way to pass a name as an extra argument ? as a symbol or string? The following don't work :(let's say we have >50 variables and we have a list for them, then using that list would be ideal.