I have a pd.multi-index with 2 levels like so
var_0 var_1
instances timepoints
0 1 1 4
2 2 5
3 3 6
4 5 8
1 1 1 4
2 2 55
3 3 6
4 3 6
2 1 1 42
2 2 5
3 3 6
What I am trying to do is convert it to a 3-dimensional NumPy array with shape (n_instances, n_columns, n_timepoints).
I have attempted to reshape using the values of the instances but this is quite a bit step up for me in terms of technicality and I'm quite stuck.
Unique_Cases = df_train.index.levels[0]
print(Unique_Cases)
D = [df_train.loc[instances].values for instances in Unique_Cases]
print(np.array(D,dtype=object).shape)