检查numpy数组是否为多维 [英] check if numpy array is multidimensional or not
本文介绍了检查numpy数组是否为多维的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查一个numpy数组是否是多维的吗?
I want to check if a numpy array is multidimensional or not?
V = [[ -7.94627203e+01 -1.81562235e+02 -3.05418070e+02 -2.38451033e+02][ 9.43740653e+01 1.69312771e+02 1.68545575e+01 -1.44450299e+02][ 5.61599000e+00 8.76135909e+01 1.18959245e+02 -1.44049237e+02]]
如何在numpy中做到这一点?
How can I do that in numpy?
推荐答案
使用 .ndim
ndarray的属性:
Use the .ndim
property of the ndarray:
>>> a = np.array([[ -7.94627203e+01, -1.81562235e+02, -3.05418070e+02, -2.38451033e+02],[ 9.43740653e+01, 1.69312771e+02, 1.68545575e+01, -1.44450299e+02],[ 5.61599000e+00, 8.76135909e+01, 1.18959245e+02, -1.44049237e+02]])
>>> a.ndim
2
这篇关于检查numpy数组是否为多维的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文