>>> from pyspark.sql.functions import PandasUDFType, pandas_udf
>>>
>>> @pandas_udf("int", PandasUDFType.GROUPED_AGG)
... def least(v):
...     return v.min()
...
>>> df = spark.createDataFrame([(1, "Hello"), (2, "Hi"), (5, "Hello"), (0, "Hello")], ["n", "text"])
>>> df.groupBy(df.text).agg(least(df.n)).sort("text").show()
+-----+--------+
| text|least(n)|
+-----+--------+
|Hello|       0|
|   Hi|       2|
+-----+--------+
