I am using julia 1.4.2.
I am trying to make pivot table using aggregate function but showing ERROR: AssertionError: !(isnothing(idx_agg))
my data frame is like
Row │ exp │ amount │
│ │ Float64 │ String │
├─────┼─────────┼─────────────────┤
│ 1 │ 290.0 │ National travel │
│ 2 │ 450.0 │ National travel │
│ 3 │ 450.0 │ Food │
│ 4 │ 70.0 │ Food │
│ 5 │ 170.0 │ Meeting │
│ 6 │ 185.0 │ Food │
@show aggregate(df1, [:exp,:amount], sum)
tacktrace:
[1] _combine(::Array{Pair,1}, ::GroupedDataFrame{DataFrame}, ::Array{Symbol,1}, ::Bool, ::Bool) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\groupeddataframe\splitapplycombine.jl:1165
[2] combine_helper(::Array{Pair,1}, ::GroupedDataFrame{DataFrame}, ::Array{Symbol,1}; keepkeys::Bool, ungroup::Bool, copycols::Bool, keeprows::Bool) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\groupeddataframe\splitapplycombine.jl:583
[3] _combine_prepare(::GroupedDataFrame{DataFrame}, ::Union{Colon, typeof(nrow), Regex, AbstractString, Signed, Symbol, Unsigned, Pair, AbstractArray{T,1} where T, All, Between, InvertedIndex}; keepkeys::Bool, ungroup::Bool, copycols::Bool, keeprows::Bool) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\groupeddataframe\splitapplycombine.jl:546
[4] #combine#378 at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\groupeddataframe\splitapplycombine.jl:466 [inlined]
[5] combine(::GroupedDataFrame{DataFrame}, ::Array{Pair{Symbol,typeof(sum)},1}) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\groupeddataframe\splitapplycombine.jl:466
[6] aggregate(::DataFrame, ::Array{Symbol,1}, ::Function; sort::Bool, skipmissing::Bool) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\deprecated.jl:424
[7] aggregate(::DataFrame, ::Array{Symbol,1}, ::Function) at C:\Users\hafez.julia\packages\DataFrames\kwVTY\src\deprecated.jl:418
[8] top-level scope at show.jl:613
I can’t replicate this, which version of DataFrames are you on?
julia> using DataFrames
julia> data = DataFrame(exp = [290.0, 450.0, 450.0, 70.0], amount = ["National travel", "National travel", "Food", "Food"])
4×2 DataFrame
│ Row │ exp │ amount │
│ │ Float64 │ String │
├─────┼─────────┼─────────────────┤
│ 1 │ 290.0 │ National travel │
│ 2 │ 450.0 │ National travel │
│ 3 │ 450.0 │ Food │
│ 4 │ 70.0 │ Food │
julia> aggregate(data, [:exp, :amount], sum)
┌ Warning: `aggregate(d, cols, f, sort=false, skipmissing=false)` is deprecated. Instead use combine(groupby(d, cols, sort=false, skipmissing=false), names(d, Not(cols)) .=> f)`
│ caller = top-level scope at REPL[15]:1
└ @ Core REPL[15]:1
0×2 DataFrame
Also let me say again: please quote your code by using triple backticks on the lines before and after your code block to quote your code and make it easier for people to read.
2 Likes