# Indexing by names, current favorites in the package space

**URL:** https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097
**Category:** Data
**Tags:** question, indexing, arrays
**Created:** [November 26, 2024, 12:30pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097 "2024-11-26T12:30:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)
#### Post date: [November 26, 2024, 12:30pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/1 "2024-11-26T12:30:34Z")

</div>

I loved AxisArrays.jl. However AxisArrays is old (designed pre1.0). It still works…ok, but I miss broadcasting and Not-.indexing. I did not learn about its newer counterparts until I had written a few weeks of analysis and got annoyed about missing functionality and namespace conflict of `axes`.

As those of you know, the ecosystem here is kind of a mess. (Too) many really nice, functional packages. All working as expected with greater or fewer bugs on the corner cases. Obligatory link to a detailed thread [long thread on AxisArray replacements](https://github.com/JuliaCollections/AxisArraysFuture/issues/1) Has anyone waded through and come back with a strong opinion? Heres what Ive found:

- AxisKeys.jl and parent NamedDims.jl (@mcabbot is a core contributor, and so inclined in this direction on the weight of the name. keyedarray[:, Key(“Person”)] is understandable for disambiguation but not as nice as keyedarray[:, “Person”] .)
- DimensionalData.jl (@rafaqz is an amazingly energetic contributor with wonderful depth of knowledge on reducing abstraction cost to zero, very up to date. I avoided this one at first only because of the package name which makes me think meters/sec etc.)
- (EDIT) NamedArrays.jl Old, but showing recent maintenance! Great name, use of pair syntax `:Person => "sally` instead of “=”, no bias toward continuum representation.
- AxisIndices.jl (@Tokazama is super talented, but this out of date by several years. Im glad they are putting their ideas into ArrayInterface because I really like this style.)

SciML backed options:

- LabeledArrays
- ArrayInterface

Maybe not exactly in the same space, closer to the output of DifferentialEquations.jl?

Finally, I wonder if anyone has tips on the meta problem of finding the best packages. Currently I look at last updated src, stars, and “do I recognize the contributors from discourse”. I guess I can now add “search Juliahub rather than Google”… 🙈

Thanks!

---

<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: [November 26, 2024, 12:38pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/2 "2024-11-26T12:38:11Z")

</div>

Same thread from 5 days ago:

> [@DimensionalData vs AxisKeys](https://discourse.julialang.org/t/dimensionaldata-vs-axiskeys/122880):
>
> Hi, it seems that [DimensionalData](https://github.com/rafaqz/DimensionalData.jl) and [AxisKeys](https://github.com/mcabbott/AxisKeys.jl) have quite a bit overlap. What are the considerations I should keep in mind for choosing between these two packages?

---

<div class="post-metadata">

### Author: ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)
#### Post date: [November 26, 2024, 12:38pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/3 "2024-11-26T12:38:48Z")

</div>

😅 how embarrasing. But looking at those links, what did you decide @nilshg? did you stick with NamedArrays or try AxisKeys or go with something else?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [November 26, 2024, 12:59pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/4 "2024-11-26T12:59:51Z")

</div>

> [@cdawg](#):
>
> SciML backed options:
> 
> - LabeledArrays
> - ArrayInterface
> 
> Maybe not exactly in the same space, closer to the output of [DifferentialEquations.jl](https://juliahub.com/ui/Packages/General/DifferentialEquations)?

ArrayInterface is an interface, not a package for direct usage of this.

ComponentArrays is the one I’d recommend for most SciML types of things. It’s very different from the others mentioned above because its purpose is to be an abstraction over a Vector, so it’s good for running things like optimization on and doing linear algebra.

SymbolicIndexingInterface is a rather interesting thing to mention in here along with MTK codegen, which works in a wildly different way and its more about disconnecting interface from implementation so that optimizations done to mathematical models can be done without changing the user’s interactions with the solver.

[![](https://global.discourse-cdn.com/julialang/original/3X/6/3/63157b3eb9435d7bbf787c63637ffc5ac1416e15.jpeg "SymbolicIndexingInterface.jl: Symbolic Indexing for Everyone | Sabharwal | JuliaCon 2024") ](https://www.youtube.com/watch?v=mLihspzF2rU)

---

<div class="post-metadata">

### Author: ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)
#### Post date: [November 26, 2024, 1:14pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/5 "2024-11-26T13:14:40Z")

</div>

Thanks for the reply! Very interesting! I think these directions are too specialized for me. Im more on the data-analysis side looking for the string multidimensional/ lightweight version of DataFrames or more mature version of AxisArrays.  
e.g. getting genes count vectors

`gene_templates[Patient = "MRP12367" , cell_type = "CD4 T",:]`

---

<div class="post-metadata">

### Author: ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)
#### Post date: [November 26, 2024, 7:33pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/6 "2024-11-26T19:33:31Z")

</div>

After some testing and playing with the ergonomics, I am leaning toward [AxisKeys.jl](https://juliahub.com/ui/Packages/General/AxisKeys) for what its worth to future users, I agree with most of the design decisions as a personal preference.

---

<div class="post-metadata">

### Author: ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)
#### Post date: [November 27, 2024, 1:59pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/7 "2024-11-27T13:59:37Z")

</div>

Im here to report back!

heres what I’ve found:

_NamedDimArrays / AxisKeys.jl_

conversion from aa::AxisArrays looks like for 2D data (Patient \ cell\_type), looks very much like AxisArray construction

```julia
    freq_ka = KeyedArray(aa.data, 
	Patient = collect(AxisArrays.axisnames(aa,1)), 
	cell_type = collect(AxisArrays.axisnames(aa,2)));    

```

negation index works via function passing

```julia
contrained_freq_ka = freq_ka[:, !in(["Tumor","Follicle"])]

```

but it doesnt work perfectly since it’s data is a view of a NamedDimArray or something complicated. Later I seemed to accidentally read the whole array instead of copying out a slice and sizes became mismatched.

The two layers of wrapping AxisKeys - NamedDimArrays cause problems as mcabbott noted in the Zulip thread. Nice API goals, surprisingly complicated and buggy imo. (NamedDimArrays works perfectly on its own, but doesnt serve my purpose)

_AxisIndices.jl_

This doesnt work in a heavy environment, the compat restrictions have become too stale.

_NamedArrays.jl_

conversion from AxisArrays can be done with

```julia
named_array_convert(aa::AxisArrays.AxisArray) = NamedArray(aa.data; dimnames = AxisArrays.axisnames(aa), names = tuple(collect.(collect(AxisArrays.axes(aa)))...))

```

Look at cell frequencies for subpopulation

```julia
let na = freq_na[:,Not(["Tumor","Stroma"])]
	na ./ sum(na,dims = 2)
end

```

Works well! I’m not worried about potential type instability. I am worried about developer pulse, but its not zero! `using`, works fine julia 1.10.5 in a heavy pluto notebook. This is what I am now using.

_DimensionalData.jl_

Looks like a great package, but I cant get over the style. Very opinionated with use of X, Y and expectation of dimensional data

from the manual:

```julia
boxplot(rand(X('a':'d'), Y(2:5:20)))

```

(Conclusion) So Ive ended up going for NamedArrays, although I cant help but feel like it is still suboptimal. Its just super hard to cover the interface of Array. I think some version of traits / concrete-type subtyping / method forwarding / classes would help alot.

(Speculation) Maybe AxisArrays could be rebuilt on ReusePatterns.jl or one of the many interesting similar packages or ideally some future julia feature. I think what one needs is a ways to specify that if any function has methods for f(a::Array,…) the same method is automatically called f((a::AxisArray), …) = f(a.data,…) and only specified new methods would get higher precedence, annotated by function g(a::AxisArray,…). Lots of work has gone into trying to replicate this behavior, although the design space is tricky.

TLDL: NamedArrays.jl for now. (Edit: formating.)

---

<div class="post-metadata">

### Author: ![Joris\_Pinkse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joris_pinkse/32/216398_2.png) [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)
#### Post date: [June 6, 2025, 8:40pm UTC](https://discourse.julialang.org/t/indexing-by-names-current-favorites-in-the-package-space/123097/8 "2025-06-06T20:40:18Z")

</div>

A late reply… I didn’t mind NamedArrays until I discovered that it won’t work nicely with some other packages, e.g. OffsetArrays
