My input dataframe: df1
line_item_product_code cost Account
AWSCloudTrail 10 AU-MGT
AWSGlue 12 AU-MGT
AWSQueueService 15 AU-MGT
AWSSecretsManager 20 AU-PRD
AmazonDynamoDB 30 AU-PRD
I want to calculate the percentage based on specific account
Output dataframe:
line_item_product_code cost Account percentage
AWSCloudTrail 10 AU-MGT 27.02
AWSGlue 12 AU-MGT 32.43
AWSQueueService 15 AU-MGT 40.54
AWSSecretsManager 20 AU-PRD 40
AmazonDynamoDB 30 AU-PRD 60
How can I achieve this in pandas? Example Calculation for AU-MGT and AWSCloudTrail:
percentage = 10*100/(10+12+15)