VOOZH about

URL: https://www.geeksforgeeks.org/data-engineering/find-minimum-maximum-and-average-value-of-pyspark-dataframe-column/

⇱ Find Minimum, Maximum, and Average Value of PySpark Dataframe column - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find Minimum, Maximum, and Average Value of PySpark Dataframe column

Last Updated : 29 Jun, 2021

In this article, we are going to find the Maximum, Minimum, and Average of particular column in PySpark dataframe.

For this, we will use agg() function. This function Compute aggregates and returns the result as DataFrame.

Syntax: dataframe.agg({'column_name': 'avg/'max/min})

Where,

  • dataframe is the input dataframe
  • column_name is the column in the dataframe

Creating DataFrame for demonstration:

Output:

👁 Image

Finding Average

Example 1: Python program to find the average of dataframe column

Output:

👁 Image

Example 2: Get average from multiple columns

Output:

👁 Image

Finding Minimum

Example 1: Python program to find the minimum value in dataframe column.

Output:

👁 Image

Example 2: Get minimum value from multiple columns

Output:

👁 Image

Finding Maximum

Example 1: Python program to find the maximum value in dataframe column

Output:

👁 Image

Example 2: Get maximum value from multiple columns

Output:

👁 Image
Comment
Article Tags: