Group Selection by Condition in DataFramesMeta.jl

Unfortunately currently this is not very easy and you have to write:

filter(:x1 => x-> any(!ismissing, x), groupby(df, :id)) |> DataFrame
filter(:x1 => x-> all(!ismissing, x), groupby(df, :id)) |> DataFrame

However, in the upcoming release of DataFrames.jl (after this PR is merged) you can write using DataFramesMeta.jl:

@chain df begin
    groupby(:id)
    @subset(any(!ismissing, :x1))
end
@chain df begin
    groupby(:id)
    @subset(all(!ismissing, :x1))
end
1 Like