【发布时间】:2017-11-08 02:22:59
【问题描述】:
我有以下数据框:
Question1 Question2 Question3 Question4
User1 Agree Agree Disagree Strongly Disagree
User2 Disagree Agree Agree Disagree
User3 Agree Agree Agree Agree
有没有办法将上面列出的数据框转换为下面的?
Agree Disagree Strongly Disagree
Question1 2 1 0
Question2 2 1 0
Question3 2 1 0
Question4 1 1 1
这和我之前的问题类似:Make a dataframe with grouped questions from three columns
我尝试使用 stack/pivot 查看以前的问题,但无法弄清楚。实际的数据框有 20 多个问题和一个李克特量表,从非常同意、同意、中立、不同意、非常不同意。
【问题讨论】:
标签: python pandas numpy group-by pandas-groupby