背景
刚开始学习spark不久,连csc_matrix是得到矩阵的函数都不清楚hhh,查阅资料发现网上csc_matrix的解释很绕口,为了给自己留个记录,也为了方便遇到同样问题的初学者,就记下了这篇备忘录(cry::要是不幸没有解释清楚,读者可以带上下面的源码跑一次)
- 应具备的python知识
有关python列表的操作:
List1【i:j】可得到新列表List2,List2的列表由从List1【i】到List1【j-1】的元素组成
即List2=【List1【i】,……,List【j-1】】
官方文档
csr_matrix((data, indices, indptr), [shape=(M, N)]) is the standard
CSR representation where the column indices for row i are stored in
indices[indptr[i]:indptr[i+1]] and their corresponding values are
stored in data[indptr[i]:indptr[i+1]]. If the shape parameter is not
supplied, the matrix dimensions are inferred from the index arrays.翻译附上: csr_matrix((data, indices, indptr), [shape=(M, N)])
是标准的CSC表示,其中列i的行索引被存储在其indices[indptr[i]: