scipy.sparse.

vstack#

scipy.sparse.vstack(blocks, format=None, dtype=None)[Quelle]#

Stapelsparse-Arrays vertikal (zeilenweise)

Parameter:
blocks

Sequenz von Sparse-Arrays mit kompatiblen Formen

formatstr, optional

Sparse-Format des Ergebnisses (z.B. "csr"), standardmäßig wird ein geeignetes Sparse-Array-Format zurückgegeben. Diese Wahl kann sich ändern.

dtypedtype, optional

Der Datentyp des Ausgabearrays. Wenn nicht angegeben, wird der dtype aus dem von blocks abgeleitet.

Rückgabe:
new_arraySparse-Matrix oder -Array

Wenn einer der Blöcke in `blocks` ein Sparse-Array ist, wird ein Sparse-Array zurückgegeben. Andernfalls wird eine Sparse-Matrix zurückgegeben.

Wenn Sie ein Sparse-Array erstellen möchten, das aus Blöcken besteht, die keine Sparse-Arrays sind, verwenden Sie block(vstack(blocks)) oder konvertieren Sie einen Block, z.B. blocks[0] = csr_array(blocks[0]).

Siehe auch

hstack

Stapelsparse-Matrizen horizontal (spaltenweise)

Beispiele

>>> from scipy.sparse import coo_array, vstack
>>> A = coo_array([[1, 2], [3, 4]])
>>> B = coo_array([[5, 6]])
>>> vstack([A, B]).toarray()
array([[1, 2],
       [3, 4],
       [5, 6]])