How to use 'numpy combine arrays into matrix' in Python

Every line of 'numpy combine arrays into matrix' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1298def concatenate_arrays(arrays):
1299 # concatenate data
1300 if all([type(array) is np.ndarray for array in arrays]):
1301 concatenation = np.concatenate(arrays)
1302 # if sparse, cast all to sparse and stack
1303 else:
1304 concatenation = sp_sparse.vstack(
1305 [
1306 array
1307 if isinstance(array, sp_sparse.csr_matrix)
1308 else sp_sparse.csr_matrix(array)
1309 for array in arrays
1310 ]
1311 )
1312 return concatenation
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets