pyspark.sql.GroupedData.count

GroupedData.count()[source]

Counts the number of records for each group.

New in version 1.3.0.

Examples

>>> sorted(df.groupBy(df.age).count().collect())
[Row(age=2, count=1), Row(age=5, count=1)]