-1

I have an array B with shape (1,9,1). Is it possible to convert into a new array B1 with shape (1,3,3)? The desired output is attached.

import numpy as np

B=np.array([[[0.67873113],
              [1.24442563],
              [0.02109   ],
              [0.76788408],
              [2.00615422],
              [3.07375839],
              [1.037729  ],
              [5.03294753],
              [0.0105    ]]])
print("B shape =",B.shape)

The desired output is

B1=np.array([[[0.67873113,1.24442563,0.02109   ],
             [0.76788408,2.00615422,3.07375839],
             [1.037729,5.03294753,0.0105    ]]])

B1 shape = (1, 3, 3)
1
  • 3
    Did you try B.reshape(1, 3, 3)? Commented Jun 22, 2022 at 6:07

1 Answer 1

1

You can just reshape it. See here

B.reshape((1,3,3))

>>> array([[[0.67873113, 1.24442563, 0.02109   ],
        [0.76788408, 2.00615422, 3.07375839],
        [1.037729  , 5.03294753, 0.0105    ]]])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.