【发布时间】:2021-04-11 22:30:16
【问题描述】:
我有一个这样的数据框:
Student_ID Subject Class_Feedback_question Class_Feedback_Answer
100101 Physics How was physics class? Excellent: 5
100101 Physics how was physics class: very good:4
100101 Physics How was the Presentation: Good: 3
100101 Chemistry How Much would you rate? Excellent: 5
100102 Math how much would you rate: Excellent: 4
100102 Physics how was presentation: Good: 3
我想让Class_Feedback_question 列中相似的行值看起来相等,(例如:在问题or 的末尾将: 设为? 保持一个问题不变,并用它替换其他类似的问题,例如:how was presentation: 替换为 How was the Presentation: )
像这样:
Student_ID Subject Class_Feedback_question Class_Feedback_Answer
100101 Physics How was physics class? Excellent: 5
100101 Physics How was physics class? very good:4
100101 Physics How was the presentation: Good: 3
100101 Chemistry How Much would you rate? Excellent: 5
100102 Math How much would you rate? Excellent: 4
100102 Physics How was the presentation: Good: 3
如何在python Pandas 中做到这一点?
另外,如何根据Class_Feedback_Answer 创建数据透视表?
【问题讨论】:
标签: python-3.x pandas dataframe pivot-table multiple-columns