【发布时间】:2018-10-02 17:44:56
【问题描述】:
我有一个 RDD,其中 ID 作为键,numpy 数组作为值。
对于数组中的每个值,我想创建另一个 RDD,对于大于 0 的值给出 1,对于等于 0 的值给出 0。
我尝试过以下代码:
RDD2 = RDD1.foreach(lambda x: 1 if np.nditer(x) > 0 else 0)/
.map(lambda x: (x[0],(x[1])))
但它给了我以下错误:AttributeError: 'NoneType' object has no attribute 'map',我不知道为什么
有什么办法可以解决这个问题吗?
谢谢
【问题讨论】:
标签: numpy apache-spark pyspark rdd