This is the raw data
a=[[1,2,3,4,5,6],
[7,8,9,10,11,12]]
I want to convert it to the format like this:
b=[[1,2,3,7,8,9],
[4,5,6,10,11,12]]
array(List).swapaxes()
How to do it use reshape and swapaxes in python?
Thanks
try this:
import numpy as np
a = np.array([[1,2,3,4,5,6], [7,8,9,10,11,12]])
b = a.reshape((2, 2, 3)).swapaxes(0, 1).reshape(2, 6)
print(b)
check it out: https://coderpad.io/F7X7EKR4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With