Google News
logo
SciPy - Interview Questions
How to create a Sparse Matrix in Python
Python’s SciPy gives tools for creating sparse matrices using multiple data structures, as well as tools for converting a dense matrix to a sparse matrix. The function csr_matrix() is used to create a sparse matrix of compressed sparse row format whereas csc_matrix() is used to create a sparse matrix of compressed sparse column format.
 
Syntax :

scipy.sparse.csr_matrix(shape=None, dtype=None) 
 
Parameters :

* shape : Get shape of a matrix
* dtype : Data type of the matrix
 
Advertisement