例如:
+------+
|items |
+------+
| 1|
| 14|
| 11|
| 3|
| 0|
| 0,13|
| 8|
| 7|
| 7,11|
| 13|
+------+
我想用同一列的其他值减去每个列的值。例如,将所有其他值减去1,然后将所有其他值(如wise最高为13)减去14。怎么可能?
我尝试了udf函数,但没有用。
df.rdd.foreach(x => {
val firstPoint= x.toSeq.toArray.map({
case s: String => s.toInt
case l: Long => l.toInt
case d :Double => d.toInt
case i : Int => i.toInt
case f : Float => f.toInt
})
println(firstPoint.deep)
items = items.withColumn("col" + i,freq(firstPoint)(df.col("items")))
i = i + 1
})
它显示空指针错误。