+3 votes
in Programming Languages by (17.0k points)

I am trying to stack 3 sparse matrices vertically. But the following code is giving an error: TypeError: vstack() got multiple values for argument 'format'.

 X_te = sparse.vstack((X1[teidx], X0_tr[teidx]), X0_te, format='csr')  # merge the data

What's wrong with this code? 

1 Answer

0 votes
by (33.7k points)

You have the variable "X0_te" outside the parenthesis. That's why it's giving error.

Make the following change and it should fix the error.

From

X_te = sparse.vstack((X1[teidx], X0_tr[teidx]), X0_te, format='csr')  # merge the data

to

X_te = sparse.vstack((X1[teidx], X0_tr[teidx], X0_te), format='csr')  # merge the data

...