Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions bag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@
"b.count().compute() # Count total number of records"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(b.groupby(lambda record:record[\"occupation\"]).map(lambda kv: ( kv[0], len(kv[1]))).compute()[:10]) # using groupby to count people in each occupation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"city_counts = b.foldby(key = lambda record:record[\"address\"][\"city\"], binop = lambda acc, record:acc + 1, initial = 0 ) # using foldby to count people living by city\n",
"city_counts.take(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading