Hi I have generated a dataframe as follows:
Data mS1 nS1 mS1S2 nS1S2
KC 1 9 1 18
KN 1 9 0 19
KD 1 9 1 18
NG 0 10 2 17
Now I want to convert each row as to a new 2x2 matrix: 1st & 3rd and 2nd & 4th columns
For example for KC:
KC 1 1
-KC 9 18
Create a dict or list comprehension, with with keys from your
Data
field, and usenumpy.ndarray.reshape
. Looks like it's also necessary to useorder='F'
for desired output:[out]
[out]