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

"For" loop over enumeration leads to TypeError #69

Closed
dominusmi opened this issue Jan 4, 2018 · 1 comment
Closed

"For" loop over enumeration leads to TypeError #69

dominusmi opened this issue Jan 4, 2018 · 1 comment

Comments

@dominusmi
Copy link

Hello,

for (i, category) in enumerate( skipmissing(train_df[:category_name] ) )
    #code
end

Leads to TypeError

TypeError: next: in typeassert, expected WeakRefString{UInt8}, got String

Stacktrace:
 [1] next(::Missings.EachSkipMissing{WeakRefStrings.WeakRefStringArray{Union{Missings.Missing, WeakRefString{UInt8}},1}}, ::Int64) at /home/edoardo/.julia/v0.6/Missings/src/Missings.jl:363
 [2] next at ./iterators.jl:65 [inlined]
 [3] anonymous at ./<missing>:?
 [4] include_string(::String, ::String) at ./loading.jl:522

where train_df is a DataFrame (DataFrames.jl) and the type of :category_name column is of type

WeakRefStrings.WeakRefStringArray{Union{Missings.Missing, WeakRefString{UInt8}},1}

I don't know if I'm using it wrong or if there is an actual issue.
For the moment my workaround is to not use skipmissing directly:

for (i, category) in enumerate( train_df[:category_name] )
    ismissing(category)
end

but from the source code which I tried to read, it seems skipmissing somehow optimised this step, ergo why I'm curious

Have a good day!

@nalimilan
Copy link
Member

I think that's due to the fact that WeakRefStringArray used to lie about its element type. It should be fixed by JuliaData/WeakRefStrings.jl#17. Closing since it's not a Missings.jl bug, but feel free to file it against WeakRefStrings if it persists with the next release.

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