action | indicator | channel | greenfield | trucking | studio
-------------------------------------------------------------
approved| cash | DM | .0067 | .2356 | .1451
approved| cash | DM | .1067 | .4549 | .4881
approved| card | EM | .2067 | .8424 | .0264
approved| card | EM | .3067 | .5949 | .1564
approved| online | RM | .4555 | .4987 | .5616
...
Hello! From the table above, I've been trying to loop through each column then add based on channel, indicator, and action with no avail. Here is a manual code I've been using in it's place:
data.loc[(data['action'] == "approved") & (data['indicator'] == "cash") &
(data['channel'] == "DM"), 'greenfield '].sum()
The end result should look like (I am creating another table, hence the column name changes):
Segment | Name | greenfield | trucking | studio
------------------------------------------------
DM |Approved| .1134 | .6905 | .6332
EM |Approved|..... |..... |.....
Any help in turning the above into a loop would be greatly appreciated!