NumPy 的 hsplit(~)
方法水平分割輸入數組。對於 2D 陣列來說,思考這個問題的一個好方法是想象垂直切割陣列。
注意
方法 hsplit(~)
隻是 split(~, axis=1)
的簡寫。為了獲得更大的靈活性,您可能需要使用 split(~)
方法。
參數
1. a
| array-like
要拆分的輸入數組。
2. split
| array-like
要進行的分割數。
返回值
包含分割的 NumPy 數組的列表。
例子
考慮以下二維數組:
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
a
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
要將 a
拆分為單獨的列:
np.hsplit(a, 3)
[array([[1],[4],[7]]),
array([[2],[5],[8]]),
array([[3],[6],[9]])]
相關用法
- Python NumPy hstack方法用法及代碼示例
- Python hashlib.sha3_256()用法及代碼示例
- Python help()用法及代碼示例
- Python BeautifulSoup has_attr方法用法及代碼示例
- Python hasattr方法用法及代碼示例
- Python http.HTTPStatus用法及代碼示例
- Python hashlib.sha3_512()用法及代碼示例
- Python help方法用法及代碼示例
- Python hashlib.shake_256()用法及代碼示例
- Python hashlib.shake_128()用法及代碼示例
- Python NumPy hypot方法用法及代碼示例
- Python hashlib.blake2s()用法及代碼示例
- Python hashlib.blake2b()用法及代碼示例
- Python hasattr()用法及代碼示例
- Python html.escape()用法及代碼示例
- Python statistics harmonic_mean()用法及代碼示例
- Python html.unescape()用法及代碼示例
- Python math hypot()用法及代碼示例
- Python hash()用法及代碼示例
- Python hashlib.sha3_224()用法及代碼示例
- Python hex方法用法及代碼示例
- Python hex()用法及代碼示例
- Python OpenCV haveImageReader()用法及代碼示例
- Python http.client.HTTPConnection.set_tunnel用法及代碼示例
- Python NumPy histogram方法用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | hsplit method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。