Split-apply-combine error

Am I doing something wrong here with the quantile line? The 3rd line with mean runs, but I’m getting the empty data vector error with the 2nd line.

This is ultimately the way I want to run it, but it’s giving the empty data vector error here as well:

image

Hard to say for certain without a minimum working example, but it looks like this:

julia> using DataFrames

julia> df = DataFrame(group = [1,1,2,2], val = [2, 3, missing, missing])
4×2 DataFrame
 Row │ group  val     
     │ Int64  Int64?  
─────┼────────────────
   1 │     1        2
   2 │     1        3
   3 │     2  missing 
   4 │     2  missing 

julia> combine(groupby(df, :group), :val => (x -> quantile(x, 0.5)) ∘ skipmissing)
ERROR: ArgumentError: empty data vector

i.e. you have groups which don’t have any dv_plasma observations, so there’s no data left to calculate the quantile from after skipmissing

3 Likes