groupBy chooses the keys of your result, and agg defines the measures. Import aggregate functions from pyspark.sql.functions so you can combine several measures in one grouped DataFrame. Aliases make the result readable and avoid downstream references to generated expression names.
Aster Supply needs order totals, customer counts and completeness measures. Those are different aggregations. count(lit(1)) counts rows, while count(col('amount')) ignores missing amounts. countDistinct counts unique known keys, and avg divides by the number of known inputs. If you group by customer_id when the request asks for region, the numbers may look sensible but answer another question. Keep each measure's meaning beside its expression while you work. Filter source rows before grouping when the business rule excludes them; filter grouped measures afterward when the threshold describes a group.