1 ,順序函數 : np.arange(15)
- 代碼 :
if __name__ == '__main__':
nd01 = np.arange(15).reshape((3,5))
print(nd01)
====================================
[[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]]
2 ,跳數 : np.arange(0,22,3)
- 代碼 :
if __name__ == '__main__':
nd01 = np.arange(0,22,3).reshape((2,4))
print(nd01)
========================
[[ 0 3 6 9]
[12 15 18 21]]
3 ,重排列 : reshape
- 代碼 :
if __name__ == '__main__':
nd01 = np.arange(15)
print(nd01)
nd01.reshape((3,5))
print(nd01)
nd01.reshape((5,3))
============================================
[ 0 1 2 3 4 5 6 7 8 9 10 11]
============================================
[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]]
============================================
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
4 ,幾維矩陣 : nd03.ndim
- 代碼 : 幾維矩陣,就返回幾
res = nd03.ndim
========================
2
5 ,元素數量 : nd02.size
1.代碼 :
if __name__ == '__main__':
nd01 = np.arange(12)
nd02 = nd01.reshape((2,6))
res = nd02.size
print(res)
=========
12