I have the following Dataframe:
Index | Plassering | Average FGrating |
---|---|---|
22943 | 1 | 100.43 |
22944 | 2 | 93.5 |
22945 | 3 | 104.6 |
22746 | 4 | 101.3 |
22947 | 1 | 102.05 |
22948 | 2 | 107.35 |
22949 | 3 | 109.12 |
I am trying to apply the softmax
function for the Average FGrating
column, for the entire DataFrame, while the Plassering
values are increasing. This means that I want to apply softmax
for the first four rows in the DataFrame, then for the next 3 rows, separately, and so on.
The entire DataFrame, having about 5000 rows, is structured like this.
My first attempt is to cycle through the rows of this DataFrame, using iterrows()
and, while Plassering
is increasing, the Average FGrating
value is added to a list. When the Plassering
value is smaller that the value from the previous row, I compute the softmax
passing the list as a parameter, then empty the list and the cycle goes on. However, I read here that it is not a good idea, performance-wise.
Do you have any better ideas than mine?