【发布时间】:2018-06-20 20:43:00
【问题描述】:
我有以下数据框
item1 item2 item3
x y z
x1 y1 z1
x y2 z2
x y z1
x2 y z
x2 y1 z2
我想找出列中每个值对列中所有值的百分比贡献(item1 中 x,x1,x2 的贡献与 item2 和 item3 相同)
以下必须是结果数据框。
item1 %con_item1 item2 %con_item2 item3 %con_item3
x 50 y 50 z 33.33
x1 16.66 y1 33.33 z1 33.33
x2 33.33 y2 16.66 z2 33.33
【问题讨论】:
-
您似乎希望我们为您编写一些代码。虽然许多用户愿意为陷入困境的程序员编写代码,但他们通常只会在发布者已经尝试自己解决问题时提供帮助。展示这种努力的一个好方法是添加Minimal, complete, verifiable example。在发帖前检查您应该完成的intro tour,尤其是How to Ask。