Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"editor.formatOnSave": false
},
"workbench.externalBrowser": "chrome",
"editor.formatOnSave": false,
"flake8.enabled": false
"editor.formatOnSave": false
}
17 changes: 2 additions & 15 deletions extras/lib/diffable.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,11 @@ def has_memory_address(cell: NotebookNode):
)


def is_value_count(source: str):
return ".value_counts(" in source


def should_clear_output(cell: NotebookNode):
"""
Ignore:
- Any system command output, since things like package paths shown in warnings/errors can change between different systems
- HTML output, since it often has generated IDs (from displacy, plotly, etc.) that change with each execution
- `value_counts()` output, since the order of the index seems to differ by machine/OS
"""

"""Ignore any system command output, since things like package paths shown in warnings/errors can change between different systems. Also clear HTML output, since it often has generated IDs (from displacy, plotly, etc.) that change with each execution."""
source = cell["source"]
return (
is_system_command(source)
or has_rich_output(cell)
or has_memory_address(cell)
or is_value_count(source)
is_system_command(source) or has_rich_output(cell) or has_memory_address(cell)
)


Expand Down
41 changes: 8 additions & 33 deletions lecture_1_demo_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 13,
"metadata": {
"editable": true,
"slideshow": {
Expand All @@ -103,22 +103,16 @@
"Illegal Parking 34297\n",
"Request Large Bulky Item Collection 30939\n",
"Blocked Driveway 25530\n",
" ... \n",
"eval(compile('for x in rang... 1\n",
"Misc. Comments\"|echo 2... 1\n",
"Bereavement Support Group 1\n",
"Misc. Comments'|echo y9v6fc... 1\n",
"Appliance 1\n",
"Name: count, Length: 248, dtype: int64"
"Name: count, dtype: int64"
]
},
"execution_count": 2,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"requests[\"Complaint Type\"].value_counts()"
"requests[\"Complaint Type\"].value_counts().head()"
]
},
{
Expand All @@ -136,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 14,
"metadata": {
"editable": true,
"id": "S90gXzXAiFoC",
Expand All @@ -156,35 +150,16 @@
"Illegal Parking 34297\n",
"Request Large Bulky Item Collection 30939\n",
"Blocked Driveway 25530\n",
" ... \n",
"Misc. Comments'|ping -c 21 ... 1\n",
"Overflowing Recycling Baskets 1\n",
"Public Assembly 1\n",
"Select Message Type... 1\n",
"{!xmlparser v='<!DOCTYPE... 1\n",
"Length: 248, dtype: int64"
"dtype: int64"
]
},
"execution_count": 3,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"requests.groupby(\"Complaint Type\").size().sort_values(ascending=False)"
]
},
{
"cell_type": "markdown",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"`.reset_index(name='count')` isn't necessary, but it's helpful to include because it allows us to name the new column that contains the count of rows."
"requests.groupby(\"Complaint Type\").size().nlargest()"
]
},
{
Expand Down