0

I have some numpy arrays of size (2, 4, 11), (2, 4, 5), (2, 4, 15).

I want to make an single array (shape [1 * 3]) like this:

array([[array(size 2, 4, 11), array(size 2, 4, 5), array(size 2, 4, 15)]], dtype=object)

I tried to call np.array([the list of arrays], dtype=object), but this error occured:

ValueError: could not broadcast input array from shape (2,4,11) into shape (2,4)

How can I do this?

minty99
  • 327
  • 1
  • 2
  • 9
  • I don't know why you want to do this, but please be aware that doing so is very rarely useful and usually a mistake. Consider using a list instead, or maybe a 2x4x31 array. – user2357112 Dec 23 '19 at 23:14
  • When the first dimensions match, this process produces an error. In this case you should go the safe route - make an 'blank' object dtype array of the right size, and assign the arrays to their respective elements. Better yet, stick with a list of arrays. – hpaulj Dec 23 '19 at 23:15

0 Answers0