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

skipping missing values #97

Open
s-celles opened this issue Jun 21, 2019 · 1 comment
Open

skipping missing values #97

s-celles opened this issue Jun 21, 2019 · 1 comment

Comments

@s-celles
Copy link

s-celles commented Jun 21, 2019

Hello,

according doc

In many cases, missing values will have to be skipped or replaced with a valid value. For example, sum([1, missing]) returns missing due to the behavior of +. Use sum(Missings.skip([1, missing]) to ignore missing values.

using Missings
sum(Missings.skip([1, missing])

is problematic (ending parenthesis is missing) but

sum(Missings.skip([1, missing]))

raises

ERROR: MethodError: no method matching skip(::Array{Union{Missing, Int64},1})

Doc (and maybe code also) should be fixed.

Maybe it should be

julia> sum(filter(!ismissing, [1, missing, 2]))
3

or with iterator

julia> sum(Iterators.filter(!ismissing, [1, missing, 2]))
3

I will personally define Missings.skip like

julia> skip(a, Missing) = Iterators.filter(!ismissing, a)
skip (generic function with 1 method)

julia> sum(skip([1, missing, 2], missing))
3

Kind regards

@s-celles
Copy link
Author

s-celles commented Jun 21, 2019

it seems that a skipmissing function exist in Base.

see https://docs.julialang.org/en/v1/manual/missing/index.html#Skipping-Missing-Values-1

Maybe Missing doc should be updated accordingly.

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 a pull request may close this issue.

1 participant