Closed s-celles closed 6 years ago
Flattening a NamedArray could help to convert it to other kind of datastructure (DataFrame...) see https://github.com/davidanthoff/IterableTables.jl/issues/65#issuecomment-345538256
That's consistent with Array
:
julia> x = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> x[:]
4-element Array{Int64,1}:
1
3
2
4
My question would be: what would the names be in such case?
The names (or value) of indexes.
...which are, for your example?
Something like
24-element Named Array{Float64,1}
A │ B │ C │
───┼───┼───┼──────────
1 │ 1 │ 1 │ ...
...
You have to be more explicit. What is the result you would have wanted?
A, B, C columns should looks like
using IterTools
collect(product(1:2,1:4,1:3))
Out[4]:
24-element Array{Tuple{Int64,Int64,Int64},1}:
(1, 1, 1)
(2, 1, 1)
(1, 2, 1)
(2, 2, 1)
(1, 3, 1)
(2, 3, 1)
(1, 4, 1)
(2, 4, 1)
(1, 1, 2)
(2, 1, 2)
(1, 2, 2)
(2, 2, 2)
(1, 3, 2)
(2, 3, 2)
(1, 4, 2)
(2, 4, 2)
(1, 1, 3)
(2, 1, 3)
(1, 2, 3)
(2, 2, 3)
(1, 3, 3)
(2, 3, 3)
(1, 4, 3)
(2, 4, 3)
and forth column (because we had a 3 dimensions NamedArray) should contains values
That kind of makes sense. But note that there's no type-stability issue here stricto sensu.
ok so I'm changing title
This would also apply to any subset-of-dimensions-preserving reshaping then, I suppose.
yes but you should noticed that n[2, :]
raises
WARNING: Partial linear indexing is deprecated. Use `reshape(A, Val{2})` to make the dimensionality of the array match the number of indices.
Thanks @davidavdav
Ah---I could have used product()
from IterTools
---I missed that, couldn't find product
.
collect(product(names(n)...))
.
Sorry I edited my post
Hello,
I noticed that
but
I was expecting a NamedArray to be returned
Kind regards