In [1]:
import numpy as np
from scipy.sparse import csr_matrix
In [2]:
l = [[0, 10, 20],
[30, 0, 40],
[0, 0, 0]]
In [3]:
csr = csr_matrix(l)
print(csr)
In [4]:
print(type(csr))
In [5]:
print(csr.shape)
In [6]:
a = np.array(l)
print(a)
In [7]:
print(type(a))
In [8]:
csr = csr_matrix(a)
print(csr)
In [9]:
print(type(csr))
In [10]:
print(csr_matrix([0, 1, 2]))
In [11]:
print(csr_matrix([0, 1, 2]).shape)
In [12]:
# print(csr_matrix([[[0, 1, 2]]]))
# TypeError: expected dimension <= 2 array or matrix
In [13]:
print(csr.toarray())
In [14]:
print(type(csr.toarray()))
In [15]:
print(csr.toarray().tolist())
In [16]:
print(type(csr.toarray().tolist()))
In [17]:
print(csr.todense())
In [18]:
print(type(csr.todense()))