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) that I have consulted says the following:
origin_brand2 = @pipe df |>
groupby(_, [:origin, :brand]) |>
combine(_, nrow)
origin_brand2 has to have a column called βnrowβ; however, I obtained a x1 column.
So, Did I do something wrong? or maybe is required to do an additional step changing the name?
Regards
1 Like
Thanks for this, OP. Glad you are working with DataFrames.
This is indeed a weird bug. However I canβt seem to replicate.
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> @pipe df |>
groupby(_, :a) |>
combine(_, :a => length => :nrow)
2Γ2 DataFrame
β Row β a β nrow β
β β Int64 β Int64 β
βββββββΌββββββββΌββββββββ€
β 1 β 1 β 2 β
β 2 β 2 β 2 β
1 Like
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