Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 21, 2021 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/eee997a2dc41310c5ee4f380736f53b9 to your computer and use it in GitHub Desktop.
Save 1ambda/eee997a2dc41310c5ee4f380736f53b9 to your computer and use it in GitHub Desktop.
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