I try to do this
import numpy as np
a = np.array([1,2,3,4],[5,6,7,8])
and I get this:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-12-ac428719fc97> in <module>
1 import numpy as np
----> 2 a = np.array([1,2,3,4],[5,6,7,8])
TypeError: Field elements must be 2- or 3-tuples, got '5'
CodePudding user response:
The problem is that all the data needs to go into the first argument, and what you want to be the second row is now being read as the specification of the data type (because that's what the second argument of the array constructor is for).
If the array you are trying to create is:
[[1 2 3 4] [5 6 7 8]]
then your code should be:
a = np.array([[1,2,3,4],[5,6,7,8]])