# A spreadsheet-like pivot function

**URL:** <https://discourse.julialang.org/t/a-spreadsheet-like-pivot-function/2701>\
**Category:** Data\
**Tags:** proposal\
**Created:** [March 16, 2017, 4:20pm UTC](https://discourse.julialang.org/t/a-spreadsheet-like-pivot-function/2701 "2017-03-16T16:20:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [March 16, 2017, 9:45pm UTC](https://discourse.julialang.org/t/a-spreadsheet-like-pivot-function/2701/2 "2017-03-16T21:45:33Z")

</div>

Interesting. DataFrames and DataTables do not support multiple column indices on purpose. This feature isn’t generally supported by database-like structures (AFAIK Pandas is an exception). If you need these, maybe you shouldn’t store the result in a `DataFrame` but in a different structure like a [`NamedArray`](https://github.com/davidavdav/NamedArrays.jl/) an [`AxisArray`](https://github.com/JuliaArrays/AxisArrays.jl) or an [`IndexedTable`](https://github.com/JuliaComputing/IndexedTables.jl). With a `DataFrame`, you would need one row for each combination of indices, with one column for each index giving the level (this is the principle of [tidy data](https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html)).

Regarding the implementation, you could probably use `aggregate`. Also, you don’t need to call `eval(op)`: just pass the function instead of its name, i.e. `sum` instead of `:sum`.

---

_[View the full topic](https://discourse.julialang.org/t/a-spreadsheet-like-pivot-function/2701)._
