I have a a dataframe containing replies from a form (20 questions -> 20 columns in the dataframe) that looks as follows :
Name | Q1 | Q2 | Q3 | Q4 | ...
A | Very well | Quite well | Quite well |Not at all | ...
B | Fairly well| Little | Very Little|Not at all | ...
C | Very well | Quite well | Quite well |Fairly well | ...
....
Note that each proficiency level is not necessarily represented in each column.
I would like to pivot this table to get a table that looks as follows :
Proficiency| Q1 | Q2 | Q3 | Q4 | ...
Very Little|NaN | NaN | B | NaN | ...
Little | NaN | B | ...
Well | NaN |
Quite well | NaN | A,C | ...
Fairly well| B |
Very well | A,C | .......
....
Basically I would like to get a table that contains the name of the people clustered by question and proficiency level. I tried to use pandas pivot_table function but didn't manage to get what I needed.
I managed to create the table by iterating on the original dataframe and creating a new dataframe. However, I was wondering if there was a simplest way to do it using some pandas functions.