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

Unable to Convert Categorical Fields #11

Open
usmcamp0811 opened this issue Sep 16, 2018 · 0 comments
Open

Unable to Convert Categorical Fields #11

usmcamp0811 opened this issue Sep 16, 2018 · 0 comments
Labels
Milestone

Comments

@usmcamp0811
Copy link

usmcamp0811 commented Sep 16, 2018

Not to a be a thorn in your side but looks like I uncovered another issue. I was playing around some more with DataFrames and converted a few fields to the Categorical Type and then piped it into Voyager and got a similar error as this one. Its pretty much the same problem as issue #9 . I don't think its a super high priority issue but something to be aware of.

data: eeg-brain-wave-for-confusion

using Queryverse 

macro __str(x)
       :(Symbol($x))
end

# load some data into a dataframe
df = load("/home/mcamp/JuliaProjects/eeg-brain-wave-for-confusion/EEG_data.csv") |> DataFrame

cols = names(df)
cols[15] = _"UserDefinedLabel" 
cols[14] = _"PreDefinedLabel"
names!(df, cols) 

categorical!(df,:SubjectID)
categorical!(df,:UserDefinedLabel)
categorical!(df,:PreDefinedLabel)
categorical!(df,:VideoID)

df |> Voyager()

Retruns:

MethodError: Cannot `convert` an object of type Float64 to an object of type CategoricalValue{Float64,UInt32}
Closest candidates are:
  convert(::Type{T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)}, !Matched::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R) at /home/mcamp/.julia/packages/CategoricalArrays/04bks/src/value.jl:65
  convert(::Type{S}, !Matched::T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)) where {S, T<:(Union{CategoricalString{R}, CategoricalValue{T,R} where T} where R)} at /home/mcamp/.julia/packages/CategoricalArrays/04bks/src/value.jl:66
  convert(::Type{T}, !Matched::T) where T at essentials.jl:154
  ...

Stacktrace:
 [1] setindex!(::Dict{Symbol,CategoricalValue{Float64,UInt32}}, ::Float64, ::Symbol) at ./dict.jl:381
 [2] Dict{Symbol,CategoricalValue{Float64,UInt32}}(::Base.Generator{Base.Iterators.Zip2{NTuple{15,Symbol},Tuple{CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32},Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32}}},getfield(DataVoyager, Symbol("##2#4"))}) at ./dict.jl:104
 [3] dict_with_eltype at ./abstractdict.jl:541 [inlined]
 [4] macro expansion at ./array.jl:591 [inlined]
 [5] dict_with_eltype at ./abstractdict.jl:546 [inlined]
 [6] Dict(::Base.Generator{Base.Iterators.Zip2{NTuple{15,Symbol},Tuple{CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32},Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32}}},getfield(DataVoyager, Symbol("##2#4"))}) at ./dict.jl:129
 [7] #1 at ./none:0 [inlined]
 [8] iterate at ./generator.jl:47 [inlined]
 [9] collect(::Base.Generator{TableTraitsUtils.TableIterator{NamedTuple{(:SubjectID, :VideoID, :Attention, :Mediation, :Raw, :Delta, :Theta, :Alpha1, :Alpha2, :Beta1, :Beta2, :Gamma1, :Gamma2, :PreDefinedLabel, :UserDefinedLabel),Tuple{CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32},Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,Float64,CategoricalValue{Float64,UInt32},CategoricalValue{Float64,UInt32}}},Tuple{CategoricalArray{Float64,1,UInt32,Float64,CategoricalValue{Float64,UInt32},Union{}},CategoricalArray{Float64,1,UInt32,Float64,CategoricalValue{Float64,UInt32},Union{}},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},CategoricalArray{Float64,1,UInt32,Float64,CategoricalValue{Float64,UInt32},Union{}},CategoricalArray{Float64,1,UInt32,Float64,CategoricalValue{Float64,UInt32},Union{}}}},getfield(DataVoyager, Symbol("##1#3"))}) at ./array.jl:619
 [10] (::Voyager)(::DataFrame) at /home/mcamp/.julia/packages/DataVoyager/h5fKO/src/DataVoyager.jl:36
 [11] |>(::DataFrame, ::Voyager) at ./operators.jl:813
 [12] top-level scope at In[18]:20

@davidanthoff davidanthoff added this to the Backlog milestone Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants