I am trying to create a 2 * 3 numpy array as below:
我正在尝试创建一个2 * 3 numpy数组,如下所示:
x_sample= np.array([31000,28.69,7055.47],[79000,3.9,16933.26]);
But I get:
但我得到:
TypeError: data type not understood
Why am I getting the error?
为什么我收到错误?
2 个解决方案
#1
3
You are missing brackets around the two lists.
您缺少两个列表的括号。
x_sample= np.array([[31000,28.69,7055.47],[79000,3.9,16933.26]])
The way it was written the dtype
argument was receiving the value [79000,3.9,16933.26]
, which obviously cannot be interpreted as a valid NumPy data type and caused the error.
写入dtype参数的方式是接收值[79000,3.9,16933.26],这显然不能被解释为有效的NumPy数据类型并导致错误。
#2
0
You can try
你可以试试
np.vstack(([31000,28.69,7055.47],[79000,3.9,16933.26]))
#1
3
You are missing brackets around the two lists.
您缺少两个列表的括号。
x_sample= np.array([[31000,28.69,7055.47],[79000,3.9,16933.26]])
The way it was written the dtype
argument was receiving the value [79000,3.9,16933.26]
, which obviously cannot be interpreted as a valid NumPy data type and caused the error.
写入dtype参数的方式是接收值[79000,3.9,16933.26],这显然不能被解释为有效的NumPy数据类型并导致错误。
#2
0
You can try
你可以试试
np.vstack(([31000,28.69,7055.47],[79000,3.9,16933.26]))