Numpy 的 rot90(~) 返回一個新的 Numpy 數組,該數組沿指定軸旋轉 90 度。
參數
1. a | array-like
輸入數組。維數必須大於 1。
2. k | int
您想要對輸入數組執行 90 度旋轉的次數。
3. axes | array_like
對於二維數組,您可以 axes=[0,1] 導致順時針旋轉,而 axes=[1,0] 導致逆時針旋轉。
返回值
沿指定軸旋轉 90 度的新 Numpy 數組
例子
假設我們有以下二維數組:
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
a
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
逆時針旋轉 90 度
np.rot(a,90 1)   # Here, k=1, which means rotation is performed just once.
array([[3, 6, 9],
       [2, 5, 8],
       [1, 4, 7]])
執行順時針旋轉 90 度
np.rot(a,90 1, axes=[1,0])
array([[7, 4, 1],
       [8, 5, 2],
       [9, 6, 3]])
相關用法
- Python NumPy roll方法用法及代碼示例
 - Python round()用法及代碼示例
 - Python NumPy roots方法用法及代碼示例
 - Python round方法用法及代碼示例
 - Python random.getstate()用法及代碼示例
 - Python random.triangular()用法及代碼示例
 - Python Numpy recarray.tostring()用法及代碼示例
 - Python reduce()用法及代碼示例
 - Python response.status_code用法及代碼示例
 - Python Numpy recarray.tobytes()用法及代碼示例
 - Python string rpartition()用法及代碼示例
 - Python numpy random.mtrand.RandomState.randn用法及代碼示例
 - Python randint()用法及代碼示例
 - Python numpy random.mtrand.RandomState.rand用法及代碼示例
 - Python Numpy recarray.min()用法及代碼示例
 - Python response.request用法及代碼示例
 - Python repr方法用法及代碼示例
 - Python Numpy recarray.cumprod()用法及代碼示例
 - Python numpy random.mtrand.RandomState.pareto用法及代碼示例
 - Python re.compile用法及代碼示例
 - Python NumPy remainder方法用法及代碼示例
 - Python Django re_path用法及代碼示例
 - Python response.elapsed用法及代碼示例
 - Python numpy random.mtrand.RandomState.standard_normal用法及代碼示例
 - Python response.cookies用法及代碼示例
 
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | rot90 method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
