NumPy 的 ndim
屬性以 int
形式返回數組的維數(或軸)。請注意,這裏的維度概念不是數學的(例如[1,2,3]
是one-dimension數組,而不是三維)。
例子
獲取一維數組的維度
x = np.array([1,2,3])
x.ndim
1
獲取二維數組的維度
x = np.array([[1,2],[3,4]])
x.ndim
2
相關用法
- Python SciPy ndimage.interpolation.geometric_transform()用法及代碼示例
- Python SciPy ndimage.spline_filter1d()用法及代碼示例
- Python SciPy ndimage.map_coordinates()用法及代碼示例
- Python scipy ndimage.sum用法及代碼示例
- Python numpy ndarray.tostring用法及代碼示例
- Python Numpy ndarray.tobytes()用法及代碼示例
- Python Numpy ndarray.getfield()用法及代碼示例
- Python numpy ndarray.dot用法及代碼示例
- Python Numpy ndarray.transpose()用法及代碼示例
- Python Numpy ndarray.flatten()用法及代碼示例
- Python Numpy ndarray.setfield()用法及代碼示例
- Python Numpy ndarray.itemset()用法及代碼示例
- Python Numpy ndarray.dot()用法及代碼示例
- Python numpy.less()用法及代碼示例
- Python networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path用法及代碼示例
- Python numpy.polynomial.hermite.hermmul用法及代碼示例
- Python numpy.seterrobj用法及代碼示例
- Python networkx.classes.function.edge_subgraph用法及代碼示例
- Python numpy.tril()用法及代碼示例
- Python numpy.around用法及代碼示例
- Python networkx.algorithms.tree.mst.maximum_spanning_edges用法及代碼示例
- Python numpy.random.standard_normal()用法及代碼示例
- Python networkx.algorithms.bipartite.basic.color用法及代碼示例
- Python numpy.select用法及代碼示例
- Python networkx.algorithms.bipartite.cluster.latapy_clustering用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | ndim property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。