Mean and empty collection

mean behaves very inconsistently with empty collections, is this intentional?

julia> y = Union{Missing, Float64}[missing, missing, missing]

julia> mean(skipmissing(y))
ERROR: ArgumentError: mean of empty collection undefined: Base.SkipMissing{Array{Union{Missing, Float64},1}}(Union{Missing, Float64}[missing, missing, missing])

julia> mean(Float64[])
NaN

julia> mean(Int64[])
NaN

julia> mean([])
ERROR: MethodError: no method matching zero(::Type{Any})

See https://github.com/JuliaLang/julia/issues/28777

1 Like

thanks for the hint.

I am working on a PR to fix this.