Is it possible to convert a DataFrame to NamedArray ?
Similar to DataFrame unstack ?
Something like
x = NamedArray( DataFrame=df, dimensions=[:D1, :D2], value = :v)
Full example. Current code:
df = DataFrame( [
(:a,:x,1),
(:b,:x,2),
(:c,:x,3),
(:a,:y,4),
(:b,:y,5),
(:c,:y,6)
])
rename!(df,[:D1,:D2,:v])
D1 = [:a,:b,:c]
D2 = [:x,:y]
l1 = length(D1)
l2 = length(D2)
x = NamedArray(ones(l1,l2), (D1,D2), (:D1,:D2))
@pipe eachrow(df) .|> ( x[ _.D1, _.D2 ] = _.v )