Skip to content

Instantly share code, notes, and snippets.

@kristoff-it
Created January 30, 2019 15:17
Show Gist options
  • Save kristoff-it/a935384160d801c009a2e8f53988f361 to your computer and use it in GitHub Desktop.
Save kristoff-it/a935384160d801c009a2e8f53988f361 to your computer and use it in GitHub Desktop.
>>> counts = df.groupby("countryCode", "occupation").agg({"en_curid": "count"})
>>> counts.show(2)
+-----------+-------------+---------------+
|countryCode| occupation|count(en_curid)|
+-----------+-------------+---------------+
| FR|MATHEMATICIAN| 34|
| IT|SOCCER PLAYER| 81|
+-----------+-------------+---------------+
only showing top 2 rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment