I'm trying to calculate the following:
- Compute the percentile rank of a value relative to a list of valuesin a different series.
- By group.
- And in an expanding
dataframewindow.
I've tried the following without success.
df['pct']=df.groupby(['Category']).expanding(1).apply(lambda x: stats.percentileofscore(df['values'],1)).reset_index(0,drop=True)