I am trying to figure out an efficient way to map data from one df to another. The first df looks like this:
entity status sum
0 Company 1 C 70
1 Company 1 E 19
2 Company 2 C 57
3 Company 2 E 71
4 Company 3 E 16
... ... ... ...
637 Company N n 16
638 Company Z E 88
639 rows × 3 columns
I want to assign them to a second data frame so that the status is represented as columns ["E", "C", "n"] (which are the values that the status column takes) with the sum as the value and at the same time the name of the company is used as the key.
The second df:
date entity sum
0 0202004 Company 1 90
1 0202004 Company 2 80
2 0202004 Company 3 30
3 0202004 Company 4 40
4 0202004 Company 5 50
... ... ... ...
28 0202004 Company 29 60
29 0202004 Company 30 70
and end df is:
date entity sum C E n
0 0202004 Company1 90 70 19 0
1 0202004 Company 2 80 71 57 0
2 0202004 Company 3 30 xy xy 0
3 0202004 Company 4 40 xy xy xy
4 0202004 Company 5 50 xy xy xy
... ... ... ...
28 0202004 Company 29 60 xy xy xy
29 0202004 Company 30 70 xy xy xy
So far I've written some low quality code that obviously doesn't work. I would be grateful for your tips and help!