DataFrame by new columns containing arrays

Ref is not treated in a special way - it will not get unwrapped (unless currently but there were no plans to change it).

What you should understand is that by and combine handle output from a functions in two kinds:

  • AbstractVecOrMat, AbstractDataFrame and NamedTuple of vectors: are one kind of allowed values to be passed (treated as tables)
  • NamedTuple mixing scalars and vectors is disallowed
  • all else is the second kind of allowed values (treated as scalars)

It is not allowed to mix scalars and tables in return values from functions working on groups of GroupedDataFrame.

Now you hit the rule:

NamedTuple mixing scalars and vectors is disallowed

There are two ways around it:

  • wrap vectors in something that is considered a scalar (a one-element tuple, a Ref, etc.)
  • wrap everything in one-element vectors (not Ref), as such vectors will get unwrapped by combine/by

So I would write:

(μ = [Point2f0(...)], color = [RGB(...)], xy = [...])
1 Like