参考 https://cloud.tencent.com/developer/article/1525041
scipy.sparse.vstack(blocks, format=None, dtype=None)[source]
Stack sparse matrices vertically (row wise)
Parameters
blocks
sequence of sparse matrices with compatible shapes
formatstr, optional
sparse format of the result (e.g. “csr”) by default an appropriate sparse matrix format is returned. This choice is subject to change.
dtypedtype, optional
The data-type of the output matrix. If not given, the dtype is determined from that of blocks.
See also
stack sparse matrices horizontally (column wise)
Examples
>>> from scipy.sparse import coo_matrix, vstack
>>> A = coo_matrix([[1, 2], [3, 4]])
>>> B = coo_matrix([[5, 6]])
>>> vstack([A, B]).toarray()
array([[1, 2],
[3, 4],
[5, 6]])
scipy.sparse.vstack函数用于将多个稀疏矩阵按行垂直堆叠。它接受一个稀疏矩阵序列作为输入,并返回一个新的稀疏矩阵。可以指定输出格式和数据类型。例子中展示了如何将两个coo_matrix矩阵堆叠并转换为数组。
823

被折叠的 条评论
为什么被折叠?



