I made a function to decile in python like so:
ttl = df['total_mrk_vol'].sum()
result = []
for i in df['total_mrk_vol']:
x = math.ceil(10*df['total_mrk_vol'].loc[df['total_mrk_vol'] <= i].sum()/ttl)
result.append(x)
df['total_decile_rank'] = result
On larger datasets this takes a long time to complete
Is there a way to make this faster/more efficient?