I am trying to parse some real data into a .mat object to be loaded in my matlab script.
I am getting this error:
TypeError: \'co
Use a sparse format, which supports efficient indexing, like dok_matrix
This is an efficient structure for constructing sparse matrices incrementally.
...
Allows for efficient O(1) access of individual elements. Duplicates are not allowed. Can be efficiently converted to a coo_matrix once constructed.
The last sentence can be generalized to: can be efficiently converted to all the other common formats if needed.
from scipy.sparse import dok_matrix
M = dok_matrix((100, 100)) # extra brackets needed as mentioned in comments
# thanks Daniel!
M[0,3] = 5