``````

In [1]:

from scipy.sparse import csr_matrix, lil_matrix

``````
``````

In [2]:

l = [[0, 10, 20],
[30, 0, 0],
[0, 0, 0]]

``````
``````

In [3]:

csr = csr_matrix(l)
print(csr)

``````
``````

(0, 1)	10
(0, 2)	20
(1, 0)	30

``````
``````

In [4]:

print(type(csr))

``````
``````

<class 'scipy.sparse.csr.csr_matrix'>

``````
``````

In [5]:

lil = csr.tolil()
print(lil)

``````
``````

(0, 1)	10
(0, 2)	20
(1, 0)	30

``````
``````

In [6]:

print(type(lil))

``````
``````

<class 'scipy.sparse.lil.lil_matrix'>

``````
``````

In [7]:

lil = lil_matrix(csr)
print(lil)

``````
``````

(0, 1)	10
(0, 2)	20
(1, 0)	30

``````
``````

In [8]:

print(type(lil))

``````
``````

<class 'scipy.sparse.lil.lil_matrix'>

``````
``````

In [9]:

lil[0, 0] = 100

``````
``````

In [10]:

print(lil.toarray())

``````
``````

[[100  10  20]
[ 30   0   0]
[  0   0   0]]

``````
``````

In [11]:

print(csr.toarray())

``````
``````

[[ 0 10 20]
[30  0  0]
[ 0  0  0]]

``````
``````

In [12]:

lil2 = lil_matrix(lil)
print(lil2.toarray())

``````
``````

[[100  10  20]
[ 30   0   0]
[  0   0   0]]

``````
``````

In [13]:

lil[0, 0] = 0

``````
``````

In [14]:

print(lil2.toarray())

``````
``````

[[ 0 10 20]
[30  0  0]
[ 0  0  0]]

``````
``````

In [15]:

lil2_copy = lil_matrix(lil, copy=True)
print(lil2_copy.toarray())

``````
``````

[[ 0 10 20]
[30  0  0]
[ 0  0  0]]

``````
``````

In [16]:

lil[0, 0] = 100

``````
``````

In [17]:

print(lil2_copy.toarray())

``````
``````

[[ 0 10 20]
[30  0  0]
[ 0  0  0]]

``````