numpy.ndarray.ndim()函數返回數組的維數。
用法: numpy.ndarray.ndim(arr)
參數:
arr :[數組]輸入數組。如果它還不是ndarray,則嘗試進行轉換。
Return :[int]返回以arr為單位的維數。
代碼1:
# Python program explaining
# numpy.ndarray.ndim() function
# importing numpy as geek
import numpy as geek
arr = geek.array([1, 2, 3, 4])
gfg = arr.ndim
print (gfg)
輸出:
1
代碼2:
# Python program explaining
# numpy.ndarray.ndim() function
# importing numpy as geek
import numpy as geek
arr = [[1, 2, 3], [4, 5, 6]]
gfg = geek.ndim(arr)
print (gfg)
輸出:
2
相關用法
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.times()用法及代碼示例
- Python PIL composite()用法及代碼示例
- Python sympy.lcm()用法及代碼示例
- Python sympy.gcd()用法及代碼示例
- Python sympy.Mod()用法及代碼示例
- Python os.pipe2()用法及代碼示例
- Python os.sendfile()用法及代碼示例
- Python os.rename()用法及代碼示例
- Python os.chmod用法及代碼示例
- Python os.kill()用法及代碼示例
- Python PyTorch sin()用法及代碼示例
- Python PIL RankFilter()用法及代碼示例
- Python os.sched_rr_get_interval()用法及代碼示例
- Python os.sched_get_priority_max()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 numpy.ndarray.ndim() method | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。