check if numpy array is multidimensional or not

后端 未结 1 1870
囚心锁ツ
囚心锁ツ 2021-02-03 18:02

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.6931         


        
相关标签:
1条回答
  • 2021-02-03 18:12

    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
    
    0 讨论(0)
提交回复
热议问题