![](/img/trans.png)
[英]How can I pivot a table and get the percentage of each row in Python?
[英]How can I calculate the percentage of each value in every row?
您可以沿行求和,然后使用总和轻松计算每列的百分比
df['Total']= df.sum(axis=0)
for col in df.columns:
df[col] = df[col] / df['Total']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.