sparkdataframe专题

sparkdataframe 对多列进行先filter后求均值

import org.apache.spark.sql.{Column, DataFrame, Dataset, Row, SparkSession} spark dataframe 对多列进行先filter后求均值 meanDf = df.select(df.columns.map(k=>mean(when(col(k)>0, col(k))).alias(k+“mean”)): _*) sp