I have a DataFrame
df = DataFrame(a = [1,1,2,2,2])
5×1 DataFrame
Row │ a
│ Int64
─────┼───────
1 │ 1
2 │ 1
3 │ 2
4 │ 2
5 │ 2
and I want to filter for the groups with let's say 2 rows - ideally with using Chain und potentially using DataFramesMeta - and I cannot get it to work.
It does work when first creating a separate column for this like so
@chain df begin
groupby(:a)
@transform(:rows = length(:a))
@subset(:rows .== 2)
end
2×2 DataFrame
Row │ a rows
│ Int64 Int64
─────┼──────────────
1 │ 1 2
2 │ 1 2
But it doesn't work when doing the same calculating it within @subset(). Anyone got a clever solution?