Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Counts the number of records for each group.
Syntax
count()
Returns
DataFrame
Examples
df = spark.createDataFrame(
[(2, "Alice"), (3, "Alice"), (5, "Bob"), (10, "Bob")], ["age", "name"])
df.groupBy(df.name).count().sort("name").show()
# +-----+-----+
# | name|count|
# +-----+-----+
# |Alice| 2|
# | Bob| 2|
# +-----+-----+