You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This throws the error MethodError: no method matching zero(::Type{Any})
This is the result of a cascade of things, most of which seem pretty reasonable in isolation, which is why it's not clear (to me anyways) what the right fix is
mean doesn't know how to handle an empty array Any[]. I don't think there's anything more reasonable for mean to do here
group seems to set the type of the dictionary elements based on the eltype of table.
I'm not sure if there's a good resolution to this. Even if group built up the groups iteratively rather than pre-allocating, for a group with only missings it would end up with an Array{Missing}, which still doesn't help mean figure out what a reasonable answer is.
My current workaround is to re-inject the type information, but it took some digging to figure out what the actual problem was, and is not pretty:
I'm not actually sure where the right place on the stack is to fix this, because it seems to cut across several layers.
Here's an example - Say I want to get the mean of each group, ignoring missings. Notice that for the
foo=2group, both elements aremissing.This throws the error
MethodError: no method matching zero(::Type{Any})This is the result of a cascade of things, most of which seem pretty reasonable in isolation, which is why it's not clear (to me anyways) what the right fix is
meandoesn't know how to handle an empty arrayAny[]. I don't think there's anything more reasonable formeanto do heretabledoesn't have usful type information (see type promotion of missing inside tuples JuliaLang/julia#31077)groupseems to set the type of the dictionary elements based on theeltypeoftable.I'm not sure if there's a good resolution to this. Even if
groupbuilt up the groups iteratively rather than pre-allocating, for a group with only missings it would end up with anArray{Missing}, which still doesn't helpmeanfigure out what a reasonable answer is.My current workaround is to re-inject the type information, but it took some digging to figure out what the actual problem was, and is not pretty:
Another workaround is setting the type of
tableexplicitly:But that gets pretty verbose.
Any thoughts as the the best way to handle this?