Combine function not naming column as cols => function => target_cols implies

The Pair(s) are resolved before being passed to the combine function. Let’s look below at what the combine function is receiving as its second argument.

Your original version is a single Pair from the column name to a function output. (The “var” thing is denoting an anonymous function.) The output of the anonymous function is a Pair, which you can see in your provided PetalLength_function column screenshot.

julia> :PetalLength => x -> mean(x) => :myMean
:PetalLength => var"#1#2"()

Julia reads the above the same way as if you would have put the parentheses around the final Pair. Written this way, you have only provided combine with a source column and an operation function.

julia> :PetalLength => x -> (mean(x) => :myMean)
:PetalLength => var"#13#14"()

julia> typeof(:PetalLength => x -> (mean(x) => :myMean))
Pair{Symbol, var"#17#18"}

You need to separate the operation function from the new column name with parentheses so that combine sees nested Pairs as its second argument.

julia> :PetalLength => (x -> mean(x)) => :myMean
:PetalLength => (var"#3#4"() => :myMean)

julia> typeof(:PetalLength => (x -> mean(x)) => :myMean)
Pair{Symbol, Pair{var"#5#6", Symbol}}

Read here to learn how to format your code snippets:

1 Like