Numpy 的 vstack(~)
方法用於垂直連接數組。
參數
1. tup
| array-like
將垂直連接的數組。
返回值
一個 Numpy 數組,其中提供的數組垂直連接。
例子
連接一維數組
x = np.array([1,2,3])
y = np.array([4,5,6])
z = np.vstack([x,y])
z
array([[1, 2, 3],
[4, 5, 6]])
請注意,您不限於一次僅連接兩個數組 - 您可以傳入任意數量的數組。
連接二維數組
x = np.array([[1,2],[3,4]])
y = np.array([[5,6],[7,8]])
z = np.vstack([x,y])
z
array([[1, 2],
[3, 4],
[5, 6],
[7, 8]])
為了更容易處理這個問題,這裏是x
和y
pretty-formatted:
x = [[1, 2], y = [[5, 6]
[3, 4]] [7, 8]]
相關用法
- Python NumPy vsplit方法用法及代碼示例
- 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 | vstack method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。