---
title: agg (DataFrame)
description: "DataFrame.agg method in PySpark: Aggregate on the entire DataFrame without groups (shorthand for df.groupBy().agg())."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/dataframe/agg
---

# agg (DataFrame)

Aggregate on the entire DataFrame without groups (shorthand for `df.groupBy().agg()`).

## Syntax

```
agg(*exprs: Union[Column, Dict[str, str]])
```

## Parameters

| Parameter | Type                                    | Description                                       |
| --------- | --------------------------------------- | ------------------------------------------------- |
| `exprs`   | Column or dict of key and value strings | Columns or expressions to aggregate DataFrame by. |

## Returns

`DataFrame`: Aggregated DataFrame.

## Examples

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
df.agg({"age": "max"}).show()
# +--------+
# |max(age)|
# +--------+
# |       5|
# +--------+
df.agg(sf.min(df.age)).show()
# +--------+
# |min(age)|
# +--------+
# |       2|
# +--------+
```
