scipy.sparse.vstack

scipy.sparse.vstack(blocks, format=None, dtype=None)

Stack sparse matrices vertically (row wise)

Parameters :

blocks :

sequence of sparse matrices with compatible shapes

format : string

sparse format of the result (e.g. “csr”) by default an appropriate sparse matrix format is returned. This choice is subject to change.

See also

hstack
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] ).todense()
matrix([[1, 2],
        [3, 4],
        [5, 6]])

Previous topic

scipy.sparse.hstack

Next topic

scipy.sparse.rand

This Page