a = np.array([1,2,3])
b = np.array([1,2,3,4])
c = np.array([a, b])
c中有两个不同大小的np.ndarray
,当我尝试调用c.astype(np.int8)
时,我会得到一个valueerror:setting a array element with a sequence.
的值错误。 如何更改C的dtype
?
要在创建过程中指定数组的类型,只需使用DType=XXX
。 例如:
c = np.array([a,b], dtype=object)
这就是你想要的吗?