Reputation: 458
I have a ndarray(example given below).
A=
[[0.1 1.1 ]
[0.1 1.3 ]
[0.25 1.25]
[0.25 1.45]
[0.37 1.37]
[0.35 1.8 ]]
I want to reshape it as
B=
[[[0.1 1.1 ] [0.1 1.3 ]]
[[0.25 1.25 ] [0.25 1.45 ]]
[[0.37 1.37 ] [0.35 1.38 ]]]
so that doing
B[0] gives me [[0.1 1.1 ] [0.1 1.3 ]] and B[0][0] gives [0.1 1.1 ]
Upvotes: 0
Views: 41
Reputation: 5935
Use standard numpy reshaping:
B = A.reshape(-1, 2, 2)
Upvotes: 1