-
技塑人生
df.sort(df("age")).show() //升序 df.sort(df.col("age").desc).show() //降序
-
如何根据dataframe中的某列数据进行排序?如:
val spark = SparkSession .builder() .appName("Test") .master("local[4]") .getOrCreate() val sqlContext = spark.sqlContext var df:DataFrame = sqlContext.createDataFrame(List( ("a", "Alice", 34), ("b", "Bob", 36), ("c", "Charlie", 30) )).toDF("id", "name", "age") spark.stop()
df.sort(df("age")).show() //升序 df.sort(df.col("age").desc).show() //降序