I'm new to python and have a rather basic question.
I want to rearrange this dataframe:
df = pd.DataFrame({
"sm1_wf1": [6, 6.1, 5.9, 6],
"sm1_wf2": [7, 7.1, 6.9, 7],
"sm2_wf1": [13, 12.9, 13.1, 13]
"sm1_wf2":[4, 3.9, 4.1, 4]})
so that each row becomes a 2x2 matrix (row name will be sm1 and sm2, while column name will be wf1 and wf2), and a total of four 2x2 matrices (one for each row in the original df). I know this could be done manually, but I want some more efficient way since the actual data has many observations.
Could someone please show me how to do that? Thank you so much.