I have a table that looks like this
| index | Group | rank | Values |
|---|---|---|---|
| 0 | a | 2 | 344.0 |
| 1 | a | 3 | NaN |
| 2 | b | 1 | 455.0 |
| 3 | a | 1 | NaN |
| 4 | b | 2 | NaN |
I want to group data by 'Group', then sort according to 'rank' and then bfill only for rank == 1. The dataset is very big so I want to avoid loops.
I tried
temp[temp['rank']<=2].sort_values('rank', ascending = True).groupby('Group').bfill(axis='rows', inplace = True)
but this gives me "backfill() got an unexpected keyword argument 'axis'"