Customize quantile in DataFrames Combine summary

Hello,

I am trying to summarize a GroupedDataFrame:

df2 =  CSV.read(raw"_Q\Test.csv");

gd = groupby(df2, :Age_Catg)

print(
    combine(gd, nrow 
        ,:Income => mean
        ,:Income => middle
        ,:Income => quantile
    )
)

The issue is that I can’t specific the quantile I want (e.g. quantile(v, 0.1))
The code currently always print 5 quantile levels [0, 0.25, 0.5, 0.75, 1] and I can’t find the syntax to customize it

thank you,

Thanks for posting! welcome to Julia and to using data frames.

First, note that you can use describe to get the statistics you want by doing.

combine(describe, groupby(df, :Age_Catg))

what you want is an anonymous function.

print(
    combine(gd, nrow 
        ,:Income => mean
        ,:Income => middle
        ,:Income => t -> quantile(t, .1)
    )
)
1 Like

Thank you, thats exactly the solution I was looking for.

:grinning: