0

Consider this sample data:

    ID     Name      question     comment
0   123    Smith     question A   good 
1   123    Smith     question B   bad 
2   444    Jones     question C   bad 
3   444    Jones     question A   good 
4   333    Williams  Question B   bad

Tried pivot and pivottable (some kind of unmelting) to try and get this ideal reshaping:

        ID     Name      question A  question B  quesetion C
    0   123    Smith     good        bad         null
    1   444    Jones     good        null        bad
    2   333    Williams  null        bad         null

This did not work:

 pd.pivot_table(data, values = 'comment', index=['ID','Name'], columns = 'question').reset_index()

I am sure there is some detail within the pivot or pivottable functions I am missing, so it's close. Thanks for taking a look.

John Taylor
  • 655
  • 6
  • 19

0 Answers0