Replace min by a quantile in a transform after groupby

Viewed 23

I am calculating the minimum of each group using this piece of code:

df['columnname'].groupby(group_identifier).transform('min')

This works well but I now want to calculate the 10% quantile of each group instead of the minimum. How do I modify my code?

1 Answers

You pass "quantile" instead of "min" and also pass the quantile cut point as q:

df[column_name].groupby(group_identifier).transform("quantile", q=0.1)
Related