This dataframe is given:
data = {'dates': ['01.05.2020', '01.05.2020', '01.05.2020', '02.05.2020', '02.05.2020', '03.05.2020', '03.05.2020'],
'amount' : [500,1000, 2000,3000,1000,4000, 2300], 'state' : ['ABC', 'ERT', 'ABC', 'XYZ', 'ERT' , 'ZEQ', 'ERT']}
In the column state we have four differerent values (ABC, ERT, XYZ & ZEQ). Now my goal is to add new columns for the amount per state in percentage for each day. Hence, we need to group by dates and then calculate the daily amount in percentage for each state.
So e.g. the first line of the new data frame should look like:
How can I do this in the easiest way?