-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nesting #13
Comments
Currently we have: julia> t = [(a = (a=1, c=33), b = (c = 1, e = 14))]
1-element Array{NamedTuple{(:a, :b),Tuple{NamedTuple{(:a, :c),Tuple{Int64,Int64}},NamedTuple{(:c, :e),Tuple{Int64,Int64}}}},1}:
(a = (a = 1, c = 33), b = (c = 1, e = 14))
julia> ct = t |> columntable
(a = NamedTuple{(:a, :c),Tuple{Int64,Int64}}[(a = 1, c = 33)], b = NamedTuple{(:c, :e),Tuple{Int64,Int64}}[(c = 1, e = 14)])
julia> ct.a
1-element Array{NamedTuple{(:a, :c),Tuple{Int64,Int64}},1}:
(a = 1, c = 33)
julia> ct.a |> columntable
(a = [1], c = [33]) So, I'm not quite sure what the question is: if we should try to do this nested unwrapping automatically? Or is the fact that this "works" good enough? Like, in your application, if you knew there would be nested rows, you'd just make sure to pivot to columns, then further pivot the resulting top-level keys. Let me know if that makes sense and feel free to correct my understanding of what you're after here. |
My evil plan is to use the machinery here to replace:
In case 1), nesting is needed because to iterate some rows that will be collected as a table with primary column we use iteration of pairs of named tuples. For example, something that iterates In case 2), nesting in needed for composite types, something like: struct A
x::Float64
y::Float64
end
struct B
x::A
y::Int
end Then if I want to collect an Potentially I would like to specify which are the "types" that would cause the unwrapping (for example, for IndexedTables it's If you think that adding this kind of functionality to Tables is tricky and would complicate the design too much compared to the benefits it brings, I could try to add this functionality to StructArrays instead using tools from here and come back with explicit requests of what tools here would make that design easier and remove code duplication. What I would like to avoid is to have complete code duplication where Tables, StructArrays and IndexedTables each define their own mechanism for collecting columns that do pretty much the same thing. |
Cool; I'm certainly open to ideas here. If you work something up in Tables.jl, I'd love to see a PR and we can see what implications there'd be. |
Not yet a PR, but I've implemented this in
Now, for any respectable table, if we In the The main issue here is that there are no definitions for In short, if you're happy with the |
Hmmmm, I'm having a hard time deciphering what |
I'm working on the PR. To clarify what I meant, here is an example: julia> using StructArrays
julia> sink = StructArray{ComplexF64}(undef, 0)
0-element StructArray{Complex{Float64},1,NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}}}
julia> itr = (i+im for i in 1:10)
Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##3#4"))}(getfield(Main, Symbol("##3#4"))(), 1:10)
julia> for el in itr
push!(sink, el)
end
julia> sink
10-element StructArray{Complex{Float64},1,NamedTuple{(:re, :im),Tuple{Array{Float64,1},Array{Float64,1}}}}:
1.0 + 1.0im
2.0 + 1.0im
3.0 + 1.0im
4.0 + 1.0im
5.0 + 1.0im
6.0 + 1.0im
7.0 + 1.0im
8.0 + 1.0im
9.0 + 1.0im
10.0 + 1.0im thanks to this method. This means that the code calling |
I don't think there's anything more in Tables.jl we need for this. |
Sorry for opening so many issues, but I am really hoping that this package can be feature rich enough to accomodate all needs from IndexedTables.jl and StructArrays.jl. One question that I was thinking about is nesting.
Meaning, if I have "nested rows" (say
[(a = (a=1, c=33), b = (c = 1, e = 14))]
), then ideally one would like to have some version ofcolumns
that returns(a = (a=[1], c=[33]), b = (c = [1], e = [14]))
.Would that be possible with Tables currently?
The text was updated successfully, but these errors were encountered: