Skip to content

Commit 225ef0a

Browse files
authored
Merge pull request #160 from afeld/lec-1-demo-fix
fix lecture 1 demo
2 parents 2a3c548 + b6ccf8d commit 225ef0a

File tree

3 files changed

+11
-50
lines changed

3 files changed

+11
-50
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
"editor.formatOnSave": false
77
},
88
"workbench.externalBrowser": "chrome",
9-
"editor.formatOnSave": false,
10-
"flake8.enabled": false
9+
"editor.formatOnSave": false
1110
}

extras/lib/diffable.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,11 @@ def has_memory_address(cell: NotebookNode):
2828
)
2929

3030

31-
def is_value_count(source: str):
32-
return ".value_counts(" in source
33-
34-
3531
def should_clear_output(cell: NotebookNode):
36-
"""
37-
Ignore:
38-
- Any system command output, since things like package paths shown in warnings/errors can change between different systems
39-
- HTML output, since it often has generated IDs (from displacy, plotly, etc.) that change with each execution
40-
- `value_counts()` output, since the order of the index seems to differ by machine/OS
41-
"""
42-
32+
"""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."""
4333
source = cell["source"]
4434
return (
45-
is_system_command(source)
46-
or has_rich_output(cell)
47-
or has_memory_address(cell)
48-
or is_value_count(source)
35+
is_system_command(source) or has_rich_output(cell) or has_memory_address(cell)
4936
)
5037

5138

lecture_1_demo_solutions.ipynb

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"cell_type": "code",
88-
"execution_count": 2,
88+
"execution_count": 13,
8989
"metadata": {
9090
"editable": true,
9191
"slideshow": {
@@ -103,22 +103,16 @@
103103
"Illegal Parking 34297\n",
104104
"Request Large Bulky Item Collection 30939\n",
105105
"Blocked Driveway 25530\n",
106-
" ... \n",
107-
"eval(compile('for x in rang... 1\n",
108-
"Misc. Comments\"|echo 2... 1\n",
109-
"Bereavement Support Group 1\n",
110-
"Misc. Comments'|echo y9v6fc... 1\n",
111-
"Appliance 1\n",
112-
"Name: count, Length: 248, dtype: int64"
106+
"Name: count, dtype: int64"
113107
]
114108
},
115-
"execution_count": 2,
109+
"execution_count": 13,
116110
"metadata": {},
117111
"output_type": "execute_result"
118112
}
119113
],
120114
"source": [
121-
"requests[\"Complaint Type\"].value_counts()"
115+
"requests[\"Complaint Type\"].value_counts().head()"
122116
]
123117
},
124118
{
@@ -136,7 +130,7 @@
136130
},
137131
{
138132
"cell_type": "code",
139-
"execution_count": 3,
133+
"execution_count": 14,
140134
"metadata": {
141135
"editable": true,
142136
"id": "S90gXzXAiFoC",
@@ -156,35 +150,16 @@
156150
"Illegal Parking 34297\n",
157151
"Request Large Bulky Item Collection 30939\n",
158152
"Blocked Driveway 25530\n",
159-
" ... \n",
160-
"Misc. Comments'|ping -c 21 ... 1\n",
161-
"Overflowing Recycling Baskets 1\n",
162-
"Public Assembly 1\n",
163-
"Select Message Type... 1\n",
164-
"{!xmlparser v='<!DOCTYPE... 1\n",
165-
"Length: 248, dtype: int64"
153+
"dtype: int64"
166154
]
167155
},
168-
"execution_count": 3,
156+
"execution_count": 14,
169157
"metadata": {},
170158
"output_type": "execute_result"
171159
}
172160
],
173161
"source": [
174-
"requests.groupby(\"Complaint Type\").size().sort_values(ascending=False)"
175-
]
176-
},
177-
{
178-
"cell_type": "markdown",
179-
"metadata": {
180-
"editable": true,
181-
"slideshow": {
182-
"slide_type": ""
183-
},
184-
"tags": []
185-
},
186-
"source": [
187-
"`.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."
162+
"requests.groupby(\"Complaint Type\").size().nlargest()"
188163
]
189164
},
190165
{

0 commit comments

Comments
 (0)