# A little problem with combine from DataFrames.jl

**URL:** https://discourse.julialang.org/t/a-little-problem-with-combine-from-dataframes-jl/39244
**Category:** New to Julia
**Tags:** dataframes
**Created:** [May 10, 2020, 8:28pm UTC](https://discourse.julialang.org/t/a-little-problem-with-combine-from-dataframes-jl/39244 "2020-05-10T20:28:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 10, 2020, 8:28pm UTC](https://discourse.julialang.org/t/a-little-problem-with-combine-from-dataframes-jl/39244/1 "2020-05-10T20:28:28Z")

</div>

Hi! I am learning the usage of DataFrames.jl from Julia Academy and I found a problem.  
When I used combine for creating a new column, the tutorial and any other material (like [this](https://juliadata.github.io/DataFrames.jl/stable/lib/functions/#DataFrames.combine)) that I have consulted says the following:

```julia
origin_brand2 = @pipe df |>
                      groupby(_, [:origin, :brand]) |>
                      combine(_, nrow) 

```

origin\_brand2 has to have a column called “nrow”; however, I obtained a x1 column.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/8/381128e94e786153453d0a60ece6c436387acfa9.png)  
So, Did I do something wrong? or maybe is required to do an additional step changing the name?  
Regards

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 10, 2020, 8:35pm UTC](https://discourse.julialang.org/t/a-little-problem-with-combine-from-dataframes-jl/39244/2 "2020-05-10T20:35:02Z")

</div>

Thanks for this, OP. Glad you are working with DataFrames.

This is indeed a weird bug. However I can’t seem to replicate.

```julia
julia> using Pipe, DataFrames

julia> df = DataFrame(a = [1, 1, 2, 2], b = rand(4));

julia> @pipe df |>
       groupby(_, :a) |>
       combine(_, nrow)
2×2 DataFrame
│ Row │ a │ nrow │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 2 │

```

It seems like you are on the latest version of DataFrames, though, so I don’t have a great answer.

Sorry this isn’t working how you expect. In the meantime you can do

```julia
julia> @pipe df |>
       groupby(_, :a) |>
       combine(_, :a => length => :nrow)
2×2 DataFrame
│ Row │ a │ nrow │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 2 │
│ 2 │ 2 │ 2 │

```

---

<div class="post-metadata">

### Author: ![ameresv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameresv/32/14372_2.png) [@ameresv](https://discourse.julialang.org/u/ameresv)
#### Post date: [May 10, 2020, 10:26pm UTC](https://discourse.julialang.org/t/a-little-problem-with-combine-from-dataframes-jl/39244/3 "2020-05-10T22:26:40Z")

</div>

Thanks for your answer. I am continuing with the course. As an R native, I like Julia and this package especially for the similarity to tidyverse. This bug doesn’t affect my motivation to learn more about it. Thanks rather for the alternative to change names.  
Regards
