I have a pandas dataframe that looks like this
Cat1 Cat2 Cat3 Amount Offset Adjust
2018-01-01 A X P 12.0 15.0 20.0
2018-01-02 B Z Q 42.0 43.0 67.0
2018-01-03 C Y R 80.0 15.0 40.0
2018-01-04 B Z R 15.0 55.0 30.0
2018-01-05 A X P 11.0 20.0 22.0
2018-01-06 A Z Q 13.0 10.0 30.0
What I am trying to achieve:
- Resample the TS at weekly level but also
- Groupby
Cat1andCat2 - Keep the first item for the remaining categorical columns
- Sum up the aggregated values for the numerical columns
The final dataframe will look like this:
2018-01-06 A X P 23.0 35.0 42.0
Z Q 13.0 10.0 30.0
B Z Q 57.0 98.0 107.0
...