Can someone tell me why using foo2, which returns a NamedTuple, with combine fails, but using foo, which returns a Tuple, is OK?
The error message I get is something about a Vector or Tuple is expected, but NamedTuple was given instead. I don't understand why returning a NamedTuple fails.
function foo(vals)
(sum(vals), mean(vals))
end
function foo2(vals)
(tot = sum(vals), avg = mean(vals))
end
df = DataFrame(:a => [1,1,2,2,3,3], :b => [10,20,30,40,50,60])
gdf = groupby(df, :a)
res = combine(gdf, :b => foo) # OK
res2 = combine(gdf, :b => foo2) # Not OK