Home > Net >  Replace min by a quantile in a transform after groupby
Replace min by a quantile in a transform after groupby

Time:02-04

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?

CodePudding user response:

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)
  •  Tags:  
  • Related