0

If I have a df that looks like this:

df = pd.DataFrame({'Col1':['A','A','A','B','B','B','C','C','C'],'Col2':[1,2,3,1,2,3,1,2,3],
                       'Col3':[0.1,0.15,0.12,0.35,0.5,0.45,0.6,0.2,0.33]})

  Col1  Col2  Col3
0    A     1  0.10
1    A     2  0.15
2    A     3  0.12
3    B     1  0.35
4    B     2  0.50
5    B     3  0.45
6    C     1  0.60
7    C     2  0.20
8    C     3  0.33

Is it possible to rearrange this so that the unique values in Col1 are my index, each value in Col2 would have it's own column, and the values in Col3 would be the DataFrames values.

So look like this, so that I could plot a heat map:

      1     2     3
A  0.10  0.15  0.12
B  0.35  0.50  0.45
C  0.60  0.20  0.33

I initially thought of groupby or something like that but it doesn't function the way I assumed it did.

Any help would be great,

Cheers

top bantz
  • 541
  • 9
  • 23

0 Answers0