I have a DataFrame with multiindex like this:
0 1 2
a 0 0.928295 0.828225 -0.612509
1 1.103340 -0.540640 -0.344500
2 -1.760918 -1.426488 -0.647610
3 -0.782976 0.359211 1.601602
4 0.334406 -0.508752 -0.611212
b 2 0.717163 0.902514 1.027191
3 0.296955 1.543040 -1.429113
4 -0.651468 0.665114 0.949849
c 0 0.195620 -0.240177 0.745310
1 1.244997 -0.817949 0.130422
2 0.288510 1.123550 0.211385
3 -1.060227 1.739789 2.186224
4 -0.109178 -1.645732 0.022480
d 3 0.021789 0.747183 0.614485
4 -1.074870 0.407974 -0.961013
What I want : array([1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0])
Now I want to generate a zero vector which have the sample length of this DataFrame and only have ones on the first elements of level[1] index. For example, here the df have a shape of (15, 3). Therefore I want to get a vector with length of 15 and should have 1 at(a, 0), (b, 2), (c, 0), (d, 3) and 0 at other points. How could I generator an vector like that? (If possible don't loop over get each sub vector and then use np.concatenate()) Thanks a lot!