位置: IT常识 - 正文

ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1

编辑:rootadmin
ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s)

目录

ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s)

问题:

解决:

完整错误:


推荐整理分享ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

问题:import numpy as np# create a 1d arrayar1 = np.array([1, 2])# create a 2d arrayar2 = np.array([[0, 0, 0], [1, 1, 1]])# hstack the arraysar_h = np.hstack((ar1, ar2))# display the concatenated arrayprint(ar_h)解决:import numpy as np# create a 1d arrayar1 = np.array([[1, 2], [1, 2]])# create a 2d array ar2 = np.array([[0, 0, 0], [1, 1, 1]])# hstack the arraysar_h = np.hstack((ar1, ar2))# display the concatenated arrayprint(ar_h)*********************************************************************[[1 2 0 0 0] [1 2 1 1 1]]完整错误:---------------------------------------------------------------------------ValueError Traceback (most recent call last)<ipython-input-2-f0ed0654d3e0> in <module> 7 8 # hstack the arrays----> 9 ar_h = np.hstack((ar1, ar2)) 10 # display the concatenated array 11 print(ar_h)<__array_function__ internals> in hstack(*args, **kwargs)D:\anaconda\lib\site-packages\numpy\core\shape_base.py in hstack(tup) 341 # As a special case, dimension 0 of 1-dimensional arrays is "horizontal" 342 if arrs and arrs[0].ndim == 1:--> 343 return _nx.concatenate(arrs, 0) 344 else: 345 return _nx.concatenate(arrs, 1)<__array_function__ internals> in concatenate(*args, **kwargs)ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s)
本文链接地址:https://www.jiuchutong.com/zhishi/283633.html 转载请保留说明!

上一篇:gnetmous.exe是什么进程 作用是什么 gnetmous进程查询(gwsloader.exe是什么意思)

下一篇:uniapp、uview——图片上传(单图上传、多图上传、多组照片上传、图片回显)(uniapp+uview)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络