Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created Dec 21, 2021
Embed
What would you like to do?
df\
    .selectExpr("brand", "price")\
    .where("brand IS NOT NULL")\
    .groupBy("brand")\
    .agg(sum("price").alias("sales_price"))\
    .orderBy(desc("sales_price"))\
    .limit(10)\
    .show(truncate=False)
+--------+------------------+
|brand |sales_price |
+--------+------------------+
|strong |2651513.6799999983|
|jessnail|2297451.200000003 |
|runail |2108654.9900000114|
|irisk |1467889.08999999 |
|grattol |1055984.4699999897|
|marathon|789238.6300000004 |
|masura |693152.7399999842 |
|cnd |599136.3200000003 |
|uno |546019.0499999991 |
|estel |544366.7999999983 |
+--------+------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment