例如,此数据取自此处:
类型 | 儿童服装 | 男式服装女式服装||
---|---|---|---|
地区 | |||
东部 | 113 | 122 | 176 |
北部 | 85 | 89 | 142 |
南部 | 45 | 39 | 53 |
西部 | 42 | 41 | 53 |
总计 | 285 | 291 | 424 |
IIUC,
output = df.astype(str).add(" ").add(df.div(df.loc["Total"]).mul(100).round().astype(int).astype(str).add("%"))
>>> output
Type Children's Clothing Men's Clothing Women's Clothing Total
Region
East 113 40% 122 42% 176 42% 411 41%
North 85 30% 89 31% 142 33% 316 32%
South 45 16% 39 13% 53 12% 137 14%
West 42 15% 41 14% 53 12% 136 14%
Total 285 100% 291 100% 424 100% 1000 100%