csc_matrix函数(学习日记)

这篇博客主要介绍了Spark中csc_matrix函数的用法,通过背景介绍和实例解析,详细阐述了如何利用csc_matrix获取矩阵数据,并解释了如何通过indices和indptr获取非零行索引及对应值,帮助初学者理解该函数。
摘要由CSDN通过智能技术生成

背景

刚开始学习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]:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值