I am looking for an efficient way to reorganize a larger Pandas DataFrame.
Suppose I have a large DF with data linked to two indexes, as shown below.
| Value | ||
|---|---|---|
| Index A | Index B | |
| A | Sample 1 | 2.3 | 
| Sample 2 | 3.1 | |
| B | Sample 1 | 5.2 | 
| Sample 2 | 1.2 | 
How can I reorganize the data into a 2D array style that still takes into maintains the pairing from the initial multi-index without using a loop iteration and reassigning the values to a new DF?
| Index A | Sample 1 | Sample 2 | 
|---|---|---|
| A | 2.3 | 5.2 | 
| B | 3.1 | 1.2 | 
I attempted to separate the DF by indexes. However due to incomplete and out of order data, transforming the row into column lost its association to the initial index A.
Currently, I am looping through the two indexes and reassociating the values in a new DF. However, the process is incredibly inefficient due to a large data set.
Thank you for your guidance.
