I have a DataFrame A
DataFrame A
| I1 | I2 | Rank |
| -------- |--------|
| 1 | a | 1 |
| 1 | b | 2 |
| 2 | a | 1 |
| 2 | b | 2 |
| 2 | c | 3 |
and I have a maximum value of rank for each I1
found by z.groupby('I1').max()
max A
| I1 | Rank |
| --- |--------|
| 1 | 2 |
| 2 | 3 |
now I want to change my dataframe base on that 2 input and make the rest NaN
Desire Output
| I1 | I2 | Rank |
| -------- |--------|
| 1 | a | NaN |
| 1 | b | num1 |
| 2 | a | NaN |
| 2 | b | NaN |
| 2 | c | num2 |
How do I achieve that?