Skip to content
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

Better interaction with tables? #71

Open
pdeffebach opened this issue Mar 27, 2024 · 1 comment
Open

Better interaction with tables? #71

pdeffebach opened this issue Mar 27, 2024 · 1 comment

Comments

@pdeffebach
Copy link

I just wrote the following function on discourse which converts an arbitrary NamedArray to a DataFrame

julia> function iteratenames(t)
           dns = (:count, dimnames(t)...)
           nms = names(t)
           out = map(vec(CartesianIndices(t))) do i
               val = t[i]
               indices = ntuple(length(nms)) do j
                  nms[j][i[j]]
               end
               vals = (val, indices...)
               NamedTuple{dns}(vals)
           end
           DataFrame(out)
       end

We could probably implement a small conversion to something that satisfied the Tables.jl interface and make it easier for people to do crosstabs that return tables.

@bkamins
Copy link
Collaborator

bkamins commented Apr 4, 2024

Indeed it is often more useful to have a DataFrame everywhere in the pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants