I want to aggregate the columns of a DataFrame based on their types, i.e something like:
function aggregate(v::Vector{T}) where T <: Number
sum(v)
end
function aggregate(v::Vector{String})
[unique(v)]
end
df = DataFrame(idx = [1, 2, 3], a = [10, 20, 30], b = ["text1", "text2", "text3"]);
test1 = combine(df, names(df) .=> aggregate)
test2 = combine(groupby(df, :idx), names(df) .=> aggregate)
What is the best way to make this work for the grouped DataFrame? The columns donβt seem to be simple vectors after applying groupby, but some kind of SubArray. Whatβs the cleanest way to make custom functions work for those types?