I have a dataframe:
d = [f1 f2 f3
1 2 3
5 1 2
3 3 1
2 4 7
.. .. ..]
I want to add, per feature, the percentile of the value for this feature in the row (for subset of features).
So for subset = [f1,f2,f3]
my dataframe will be
new_d =[f1 f2 f3 f1_per f2_per f3_per
1 2 3 0 0.25 0.5
5 1 2 1 0 0.25
3 3 1 0.5 0.5 0
2 4 5 0.25 0.75 1
4 5 4 0.75 1 0.75]
What is the best way to do so?
In ouput are 5 rows, in input are 4 rows, so output is different is use
DataFrame.rank
with all columns and join back to originalIf need rank with percentile by number of rows without
1
: