Skip to content

Conversation

@dietercastel
Copy link
Contributor

This includes a dependency on DataFrame of course. Example usage below.

using Test, DataFrames
include("test/init-namedarrays.jl")
julia> n
2×4 Named Array{Float64,2}
A ╲ B │         a          b          c          d
──────┼───────────────────────────────────────────
one   │  0.018457  0.0866435   0.738128  0.0961264
two   │  0.458486   0.629748   0.380246   0.785477

julia> cn = convert(NamedArray,n)
2×4 Named Array{Float64,2}
A ╲ B │         a          b          c          d
──────┼───────────────────────────────────────────
one   │  0.018457  0.0866435   0.738128  0.0961264
two   │  0.458486   0.629748   0.380246   0.785477

julia> ccn = convert(NamedArray,cn)
2×4 Named Array{Float64,2}
A ╲ B │         a          b          c          d
──────┼───────────────────────────────────────────
one   │  0.018457  0.0866435   0.738128  0.0961264
two   │  0.458486   0.629748   0.380246   0.785477

@test n == ccn

@dietercastel
Copy link
Contributor Author

This PR becomes moot if #99 is merged.

"""
function convert(t::Type{NamedArray}, df::DataFrame; valueCol = :Values)
newdimnames = propertynames(df)
deleteat!(newdimnames,findfirst(x->x==:Values,newdimnames))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want here :
deleteat!(newdimnames,findfirst(x->x==valueCol,newdimnames))
rather than:
deleteat!(newdimnames,findfirst(x->x==:Values,newdimnames))

@davidavdav davidavdav closed this Apr 27, 2021
@davidavdav davidavdav deleted the branch davidavdav:master April 27, 2021 07:39
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

Successfully merging this pull request may close these issues.

3 participants