I have a dataframe structure like below:
No A B C D Group
=========================
1 2 3 1 4 GA
2 4 5 3 1 GA
3 8 6 1 3 GA
4 6 1 3 2 GB
5 8 9 1 2 GB
6 8 1 9 1 GB
I want to calculate each cell percentage by their respective group.
Is there any faster way rather than looping? The size is really big so I need a faster method.
My expected result:
No A B C D Group
=======================================
1 2/14 3/14 1/5 4/8 GA
2 4/14 5/14 3/5 1/8 GA
3 8/14 6/14 1/5 3/8 GA
4 6/22 1/11 3/13 2/5 GB
5 8/22 9/11 1/13 2/5 GB
6 8/22 1/11 9/13 1/5 GB