-1
import numpy as np

A = np.array([[2], [1], [3]])

A.shape  # (3, 1)

A.reshape(3,0)
ValueError                                Traceback (most recent call last)
<ipython-input-12-771b3dbc4936> in <module>
----> 1 A.reshape(3,0)

ValueError: cannot reshape array of size 3 into shape (3,0)
luk2302
  • 55,258
  • 23
  • 97
  • 137

2 Answers2

0
import numpy as np
A = np.array([[2], [1], [3]])
A = [a for b in A for a in b]
print(A)

Results in: [2, 1, 3]

if this is what you were looking for

Tr3ate
  • 138
  • 5
  • can you please explain how this loop [a for b in A for a in b] works? – Deblu Sahu Nov 03 '22 at 09:07
  • @DebluSahu Please look [here](https://stackoverflow.com/questions/20639180/explanation-of-how-nested-list-comprehension-works) to see how nestled list comprehension works :) – Tr3ate Nov 03 '22 at 09:58
0

Please tell us about what exactly you want to achive?

A shape of (3, 1) means you have an array with two axis; one with the length of 3, and the second with one element each. Reshaping it to shape (3, 0) would give something like [[], [], []] (3 elements in the first axis and zero in the second), which doesnt really make any sense

stukoi
  • 33
  • 4