I have this data frame, where ID is a person code. The amount variable must be the same during the hold period, but I find that in certain cases the values are rounded.
| ID | period | amount | share |
|---|---|---|---|
| 1x | 202001 | 99.87 | 9.87 |
| 1x | 202002 | 99.87 | 9.87 |
| 1x | 202003 | 99.87 | 9.87 |
| 1x | 202004 | 100 | 9.87 |
| 1x | 202005 | 99.87 | 9.87 |
| 1x | 202006 | 99.87 | 9.87 |
| 2x | 202105 | 111.11 | 11.11 |
| 2x | 202106 | 111.11 | 11.11 |
| 2x | 202107 | 110 | 11.11 |
| 2x | 202108 | 111.11 | 11.11 |
| 2x | 202109 | 111.11 | 11.11 |
| 2x | 202110 | 111.11 | 11.11 |
I have to find all the similar cases and modify the value in amount. The case is that this round staff could happen with different persons and in different periods. I wish to get this df:
| ID | period | amount | share |
|---|---|---|---|
| 1x | 202001 | 99.87 | 9.87 |
| 1x | 202002 | 99.87 | 9.87 |
| 1x | 202003 | 99.87 | 9.87 |
| 1x | 202004 | 99.87 | 9.87 |
| 1x | 202005 | 99.87 | 9.87 |
| 1x | 202006 | 99.87 | 9.87 |
| 2x | 202105 | 111.11 | 11.11 |
| 2x | 202106 | 111.11 | 11.11 |
| 2x | 202107 | 111.11 | 11.11 |
| 2x | 202108 | 111.11 | 11.11 |
| 2x | 202109 | 111.11 | 11.11 |
| 2x | 202110 | 111.11 | 11.11 |
Anyone has to fix something like this?