0

I have 3 numpy csr matrixes a, b, c of shape
(69918, 7559)
(17480, 7559)
(21850, 7559)

these are the return of numpy.hstack((some matrices ....)).to_csr()

I want to join them and convert them into shape
(69918+17480+21850, 7559)

How should I do it. I tried numpy.vstack function but that converts it into (3, 1) shape

Asis
  • 183
  • 3
  • 15
  • sparse.vstack or hstack – hpaulj Nov 17 '19 at 00:01
  • I previously tried numpy.vstack that gives error. But scipy.sparse.vstack solves our problem. – Asis Nov 17 '19 at 00:09
  • 1
    The numpy functions don't know anything about sparse matrices. They just wrap each matrix in a `np.array(a)`, which as you'll see makes a 0d object dtype array. `a.toarray()` is the correct way to make a dense array. `sparse.vstack` takes an entirely different approach to joining sparse matrices. – hpaulj Nov 17 '19 at 01:19

0 Answers0