numpy csr to matrix code example Example: convert ndarray to csr_matrix sparse_csr_mat = sparse.csr_matrix(an_array)