I have an numpy array which looks like this:
+----+-------+----------------+
| id | class | probability |
+----+-------+----------------+
| 0 | 0 | 0.371301944865 |
| 0 | 1 | 0.317619162391 |
| 0 | -1 | 0.311078922721 |
| 1 | 0 | 0.401434454687 |
| 1 | 1 | 0.316000976419 |
| 1 | -1 | 0.282564557522 |
| 2 | 1 | 0.361490456577 |
| 2 | 0 | 0.324832048066 |
| 2 | -1 | 0.313677512904 |
| . | . | . |
| . | . | . |
| . | . | . |
+----+-------+----------------+
or more formally:
x = numpy.array([[ 0.00000000e+00, 0.00000000e+00, 3.71301945e-01],
[ 0.00000000e+00, 1.00000000e+00, 3.17619162e-01],
[ 0.00000000e+00, -1.00000000e+00, 3.11078923e-01],
[ 1.00000000e+00, 0.00000000e+00, 4.01434455e-01],
[ 1.00000000e+00, 1.00000000e+00, 3.16000976e-01],
[ 1.00000000e+00, -1.00000000e+00, 2.82564558e-01],
[ 2.00000000e+00, 1.00000000e+00, 3.61490457e-01],
[ 2.00000000e+00, 0.00000000e+00, 3.24832048e-01],
[ 2.00000000e+00, -1.00000000e+00, 3.13677513e-01]])
As you can see, for each id, I have three classes, each with its probability. I would like to transform this to a four column array like this:
id/class -1 0 1
0 0.311078922721 0.371301944865 0.317619162391
1 0.282564557522 0.401434454687 0.316000976419
. . . .
. . . .
. . . .
Is there a quick/clean way to do this?!