# Combine function not naming column as cols =\> function =\> target\_cols implies

**URL:** <https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831>\
**Category:** New to Julia\
**Tags:** question, dataframes\
**Created:** [May 28, 2024, 11:52am UTC](https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831 "2024-05-28T11:52:21Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [May 28, 2024, 2:53pm UTC](https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831/5 "2024-05-28T14:53:44Z")

</div>

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-repl
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-repl
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 `Pair`s as its second argument.

```julia-repl
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:

> [@PSA: how to quote code with backticks](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530):
>
> This is a short post on how to use backticks (` and ```) to quote code, so it is easy to read. This post can be linked to new users who are confused by this feature. Why By quoting your code, you get a monospaced font (which preserves indentation) and syntax highlighting. This makes it easier to read your code and help you. Displayed code looks like this: function displayed\_code(x::Int, y::Int) if x \< y println("x is smaller") else println("or not") end end Inline…

---

_[View the full topic](https://discourse.julialang.org/t/combine-function-not-naming-column-as-cols-function-target-cols-implies/114831)._
