type(A)
<class 'scipy.sparse.csc.csc_matrix'>
A.shape
(8529, 60877)
print A[0,:]
(0, 25) 1.0
(0, 7422) 1.0
(0, 26062) 1.0
(0, 31804) 1.0
(0, 41602) 1.0
(0, 43791) 1.0
print A[1,:]
(0, 7044) 1.0
(0, 31418) 1.0
(0, 42341) 1.0
(0, 47125) 1.0
(0, 54376) 1.0
print A[:,0]
#nothing returned
現在我不明白的是,當我鍵入A [1 ,:]應該從第二行選擇元素,但我從打印的第一行獲取元素。當我鍵入A [:,0]應該返回第一列,但我什麼也沒有打印。爲什麼?如何訪問稀疏矩陣元素?
打印'a [0,:]。toarray()'可能會提供更多信息。 – 2013-02-27 15:52:02
@larsmans:+1,我添加了'print a [1,:]。toarray()'。 – 2013-02-27 15:54:16
是不是可以選擇列? – siamii 2013-02-27 16:32:54