0

I have data that looks like this:

    usr value   type
0   1   2.53    A
1   2   2.38    A
2   3   2.10    B
3   4   2.10    B
4   5   3.05    C
5   6   3.05    C
6   7   2.32    D
7   8   2.32    D

There are equal number of rows with each type (i.e 2 rows with type 'A','B','C' and 'D').

I want to create a new DF that looks like this:

    A    B    C     D
0   2.53 2.10 3.05  2.32
1   2.38 2.10 3.05  2.32

I have tried using pivot_table but it creates a table with NaN values in it like this:

    A    B      C       D
0   NaN  NaN    2.53    NaN
1   NaN  NaN    2.10    NaN
2   NaN  3.05   NaN     NaN
3   NaN  2.32   NaN     NaN
4   2.38 NaN    NaN     NaN
5   2.51 NaN    NaN     NaN
6   NaN  NaN    NaN     2.35
7   NaN  NaN    NaN     2.35

0 Answers0