spark dataframe 新增一列递增索引列
import org.apache.spark.sql.expressions.Window
import org.apache.spark.sql.functions.row_number
val w = Window.orderBy("features") // 以“”features“”列为基准
var indexdata = dataset.withColumn("index", row_number().over(w))
import org.apache.spark.sql.expressions.Window
import org.apache.spark.sql.functions.row_number
val w = Window.orderBy("features") // 以“”features“”列为基准
var indexdata = dataset.withColumn("index", row_number().over(w))