Max

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

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

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

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

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

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

+---------------+
|max(Population)|
+---------------+
| 39250017|
+---------------+
..................Content has been hidden....................

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