Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

percentileofscore groupby expanding

$
0
0

I'm trying to calculate the following:

  1. Compute the percentile rank of a value relative to a list of valuesin a different series.
  2. By group.
  3. And in an expanding dataframe window.

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)

Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>