I would like to reform the following dataframe

into :

Could somebody help me with that, please?
I would like to reform the following dataframe

into :

Could somebody help me with that, please?
mozway
On
You can use the underlying numpy array:
n = 2
df = pd.DataFrame(df.values.reshape(-1,df.shape[1]//n, n)
.reshape(-1, n, order='F'),
columns=[f'node{i+1}' for i in range(n)])
Example:
node1 node2
0 0 1
1 6 7
2 2 3
3 8 9
4 4 5
5 10 11
Used input:
0 1 2 3 4 5
0 0 1 2 3 4 5
1 6 7 8 9 10 11
NB. The input must have an even number of columns (or multiple of n for the generic case).
A screenshot is not a good format for community to reproduce your code, and data.
That is a shape(m, n) to shape(u, v) problem, probably you don't know the term in Pandas, Numpy, but still can trynna google "reform", or "reshape".
We can use
np.hsplit()andnp.vstack()to deal with,shape calculation: (9 × 12) = c×(9 × n), with n = 2