I have tried searching on stackoverflow for a solution but to no avail.
Dataframe
|CustomerID |Receipt Amount |Date of spending|
|:----------|:--------------|:---------------|
|A |500 |1Oct2021 |
|A |600 |2Oct2021 |
|A |700 |3Oct2021 |
|B |200 |4Oct2021 |
|B |300 |5Oct2021 |
|B |400 |6Oct2021 |
I would like to generate a column based on the highest the person have spent via receipt amount and return that amount.
Outcome
| CustomerID | Receipt Amount | Date of spending | Column to create |
|---|---|---|---|
| A | 500 | 1Oct2021 | 700 |
| A | 600 | 2Oct2021 | 700 |
| A | 700 | 3Oct2021 | 700 |
| B | 200 | 4Oct2021 | 400 |
| B | 300 | 5Oct2021 | 400 |
| B | 400 | 6Oct2021 | 400 |
Tried the apply function but am unsure of the way to look at CustomerID and get the max amount only for the same ones. Appreciate any assistance please, thanks!