# ERROR: AssertionError: !(isnothing(idx\_agg))

**URL:** <https://discourse.julialang.org/t/error-assertionerror-isnothing-idx-agg/42055>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [June 25, 2020, 6:09pm UTC](https://discourse.julialang.org/t/error-assertionerror-isnothing-idx-agg/42055 "2020-06-25T18:09:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hafez\_ahmad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hafez_ahmad/32/14423_2.png) [@hafez\_ahmad](https://discourse.julialang.org/u/hafez_ahmad)\
**Post date:** [June 25, 2020, 6:09pm UTC](https://discourse.julialang.org/t/error-assertionerror-isnothing-idx-agg/42055/1 "2020-06-25T18:09:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 26, 2020, 9:33am UTC](https://discourse.julialang.org/t/error-assertionerror-isnothing-idx-agg/42055/2 "2020-06-26T09:33:51Z")

</div>

I can’t replicate this, which version of DataFrames are you on?

```julia
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.
