im new to python and trying to understand data manipulation
df
Alpha AlphaComboCount
12-99 8039
22-99 1792
12-99,138-99 1776
12-45,138-45 1585
21-99 1225
123-99 1145
121-99 1102
21-581 1000
121-99,22-99 909
32-99 814
21-141 75
12-581,12-99 711
347-99 685
2089-281 685
123-49,121-29,22-79 626
121-99,123-99,22-99 4
As you can see above, there are two columns. Alpha being a string made out of concatenation of 2 codes seperated by '-'. My objective is to find the aggregate percentage of alphacombocount by the first code. For example:
where there is 21 subcode-
Alpha AlphaComboCount Percent
21-99 1225 53%
21-141 75 3.2%
21-581 1000 43.3%
The objective as you see above is to get a corresponding percentage. since the total aggregrate here is 2300 of the 21 subcode.
Where it gets more complicated is for combination codes:
123-49,121-29,22-79 626 99%
121-99,123-99,22-99 4 0.6%
As you see above, all the first sub codes are the same but rearranged. This is also a valid case to get percentage values. As long as the combination is the same of the first subcode before'-'. How can i go about this to get the percentage values for all alpha combinations? is there an algorithm for this?