Min

The minimum of the column value of one of the columns in the DataFrame. An example is if you want to find the minimum temperature of a city.

The min API has several implementations, as follows. The exact API used depends on the specific use case:

def min(columnName: String): Column
Aggregate function: returns the minimum value of the column in a group.

def min(e: Column): Column
Aggregate function: returns the minimum value of the expression in a group.

Let's look at an example of invoking min on the DataFrame to print the minimum Population:

import org.apache.spark.sql.functions._
scala> statesPopulationDF.select(min("Population")).show

+---------------+
|min(Population)|
+---------------+
| 564513|
+---------------+
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.132.193