[英]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.