val file = spark.read.format(“csv”).option(“sep”,";").option(“header”,“true”).load(“house.csv”)
import spark.implicits._
//打乱顺序
val rand = new Random()
val data = file.select(“square”,“price”).map(
row => (row.getAsString.toDouble,row.getString(1).toDouble,rand.nextDouble()))
.toDF(“square”,“price”,“rand”).sort(“rand”)
登录后可查看更多问答,登录/注册