NumPy 的 vsplit(~)
方法垂直分割輸入數組。對於 2D 數組來說,思考這個問題的一個好方法是想象水平切割數組。
注意
方法 vsplit(~)
隻是 split(~, axis=0)
的簡寫。為了獲得更大的靈活性,您可能需要使用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.vsplit(a, 3)
[array([[1, 2, 3]]), array([[4, 5, 6]]), array([[7, 8, 9]])]
相關用法
- Python NumPy vstack方法用法及代碼示例
- Python Tableau views.get用法及代碼示例
- Python Tableau views.populate_csv用法及代碼示例
- Python statistics variance()用法及代碼示例
- Python venv.EnvBuilder.create用法及代碼示例
- Python Tableau views.get_by_id用法及代碼示例
- Python Tableau views.populate_pdf用法及代碼示例
- Python Tableau views.populate_preview_image用法及代碼示例
- Python vars()用法及代碼示例
- Python Tableau views.populate_image用法及代碼示例
- Python NumPy var方法用法及代碼示例
- Python NumPy view方法用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python NumPy fliplr方法用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python numpy.less()用法及代碼示例
- Python Matplotlib.figure.Figure.add_gridspec()用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python Django File.save用法及代碼示例
- Python NumPy squeeze方法用法及代碼示例
- Python Sympy Permutation.list()用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | vsplit method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。