I wonder, what is the best way to apply window functions to DataFrames? In simplest case, window functions is a sort of aggregating functions that don’t change number of rows of original dataframe and only adds some new columns. I was able to do what I want with the following code:
df = DataFrame(a = [1, 1, 2, 2], b = [1, 3, 8, 10])
by(df, :a) do d
DataFrame(b = d[:b], bmax = maximum(d[:b]), bmin = minimum(d[:b]))
end
but it feels very ugly. First of all creation of new DataFrames looks excessive, and secondly creation of column b
is very repetitive. If I have one column it’s more or less fine, but in case of 10 or 50 columns retyping them again and again is way too much. I have a feeling that I am missing something obvious here.