[英]TypeError: concatenate() got an unexpected keyword argument 'dtype'
I can clearly see an argument named dtype
in numpy documentation .我可以在numpy 文档中清楚地看到一个名为dtype
的参数。
What I can't do, is this:我不能做的是:
np.concatenate((np.array([]),np.array([3,4])),dtype=np.int64)
Which gives this error:这给出了这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<__array_function__ internals>", line 4, in concatenate
TypeError: concatenate() got an unexpected keyword argument 'dtype'
Without the dtype
argument I get this array:没有dtype
参数我得到这个数组:
>>> np.concatenate((np.array([]),np.array([3,4])))
array([3., 4.])
But I don't want those to be decimal points (float) values.但我不希望那些是小数点(浮点)值。
Why can't I use the dtype
argument?为什么我不能使用dtype
参数? How to make it int on concatenation even if my initial arrays had let's say float values?即使我最初的 arrays 让我们说浮点值,如何在串联时将其设为int ?
The documentation for dtype
says: dtype
的文档说:
New in version 1.20.0.版本 1.20.0 中的新功能。
Version 1.20.0
has only been released in Jan 2021 . 1.20.0
版本仅在 2021 年 1 月发布。
Check if you have the right version installed.检查您是否安装了正确的版本。
If you look at the documentation of version 1.19 , dtype
was not an argument of concatenate
.如果您查看版本 1.19的文档,则dtype
不是concatenate
的参数。 So dtype
was introduced in version 1.20.所以dtype
是在 1.20 版本中引入的。
Then you can update your numpy version.然后您可以更新您的 numpy 版本。 Otherwise, if your first array is of type np.int64
and the second one contains only int
, the resulting type is np.int64
.否则,如果您的第一个数组是np.int64
类型,而第二个数组仅包含int
,则结果类型为np.int64
。
np.concatenate((np.array([], dtype=np.int64), np.array([3, 4])))
array([3, 4])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.