Skip to content

Commit b247f29

Browse files
committed
Running the notebooks throuh black
1 parent 9ed54ab commit b247f29

3 files changed

Lines changed: 217 additions & 165 deletions

File tree

notes/I-Nested_Structures.ipynb

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
" \"Panos\": \"212-998-0803\",\n",
2929
" \"Maria\": \"656-233-5555\",\n",
3030
" \"John\": \"693-232-5776\",\n",
31-
" \"Jake\": \"415-794-3423\"\n",
31+
" \"Jake\": \"415-794-3423\",\n",
3232
"}"
3333
]
3434
},
@@ -80,7 +80,7 @@
8080
" \"Panos\": [\"212-998-0803\", \"917-888-4455\"],\n",
8181
" \"Maria\": [\"656-233-5555\"],\n",
8282
" \"John\": [\"693-232-5776\"],\n",
83-
" \"Jake\": [\"415-794-3423\"]\n",
83+
" \"Jake\": [\"415-794-3423\"],\n",
8484
"}"
8585
]
8686
},
@@ -134,19 +134,10 @@
134134
"outputs": [],
135135
"source": [
136136
"phones = {\n",
137-
" \"Panos\": {\n",
138-
" \"Work\": \"212-998-0803\",\n",
139-
" \"Cell\": \"917-888-4455\"\n",
140-
" },\n",
141-
" \"Maria\": {\n",
142-
" \"Work\": \"656-233-5555\"\n",
143-
" },\n",
144-
" \"John\": {\n",
145-
" \"Cell\": \"693-232-5776\"\n",
146-
" },\n",
147-
" \"Jake\": {\n",
148-
" \"Home\": \"415-794-3423\"\n",
149-
" }\n",
137+
" \"Panos\": {\"Work\": \"212-998-0803\", \"Cell\": \"917-888-4455\"},\n",
138+
" \"Maria\": {\"Work\": \"656-233-5555\"},\n",
139+
" \"John\": {\"Cell\": \"693-232-5776\"},\n",
140+
" \"Jake\": {\"Home\": \"415-794-3423\"},\n",
150141
"}"
151142
]
152143
},
@@ -181,10 +172,10 @@
181172
"outputs": [],
182173
"source": [
183174
"phones = {\n",
184-
" 'Jake': ['343-342-5455', '343-656-8766'],\n",
185-
" 'John': ['693-232-5776'],\n",
186-
" 'Maria': ['656-233-5555'],\n",
187-
" 'Panos': ['212-998-0803', '917-888-4455', '800-929-2923']\n",
175+
" \"Jake\": [\"343-342-5455\", \"343-656-8766\"],\n",
176+
" \"John\": [\"693-232-5776\"],\n",
177+
" \"Maria\": [\"656-233-5555\"],\n",
178+
" \"Panos\": [\"212-998-0803\", \"917-888-4455\", \"800-929-2923\"],\n",
188179
"}"
189180
]
190181
},
@@ -201,7 +192,7 @@
201192
"metadata": {},
202193
"outputs": [],
203194
"source": [
204-
"phones['Panos']"
195+
"phones[\"Panos\"]"
205196
]
206197
},
207198
{
@@ -217,7 +208,7 @@
217208
"metadata": {},
218209
"outputs": [],
219210
"source": [
220-
"phones.get('Panos')"
211+
"phones.get(\"Panos\")"
221212
]
222213
},
223214
{
@@ -233,7 +224,7 @@
233224
"metadata": {},
234225
"outputs": [],
235226
"source": [
236-
"phones['Panos'][1]"
227+
"phones[\"Panos\"][1]"
237228
]
238229
},
239230
{
@@ -242,7 +233,7 @@
242233
"metadata": {},
243234
"outputs": [],
244235
"source": [
245-
"phones.get('Panos')[1]"
236+
"phones.get(\"Panos\")[1]"
246237
]
247238
},
248239
{
@@ -259,10 +250,10 @@
259250
"outputs": [],
260251
"source": [
261252
"phones = {\n",
262-
" \"Panos\": {\"Work\":\"212-998-0803\", \"Cell\": \"917-888-4455\"},\n",
263-
" \"Maria\": {\"Work\":\"656-233-5555\"},\n",
264-
" \"John\": {\"Cell\":\"693-232-5776\"},\n",
265-
" \"Jake\": {\"Home\":\"415-794-3423\"}\n",
253+
" \"Panos\": {\"Work\": \"212-998-0803\", \"Cell\": \"917-888-4455\"},\n",
254+
" \"Maria\": {\"Work\": \"656-233-5555\"},\n",
255+
" \"John\": {\"Cell\": \"693-232-5776\"},\n",
256+
" \"Jake\": {\"Home\": \"415-794-3423\"},\n",
266257
"}"
267258
]
268259
},
@@ -272,7 +263,7 @@
272263
"metadata": {},
273264
"outputs": [],
274265
"source": [
275-
"phones['Panos']['Cell']"
266+
"phones[\"Panos\"][\"Cell\"]"
276267
]
277268
},
278269
{
@@ -289,11 +280,36 @@
289280
"outputs": [],
290281
"source": [
291282
"citibike_stations = [\n",
292-
" {'station_id': 72, 'capacity': 39, 'coords': {'lon': -73.9939, 'lat': 40.7673}, 'name': 'W 52 St & 11 Ave', },\n",
293-
" {'station_id': 79, 'capacity': 33, 'coords': {'lon': -74.0067, 'lat': 40.7191}, 'name': 'Franklin St & W Broadway'},\n",
294-
" {'station_id': 82, 'capacity': 27, 'coords': {'lon': -74.0002, 'lat': 40.7673}, 'name': 'St James Pl & Pearl St'},\n",
295-
" {'station_id': 83, 'capacity': 62, 'coords': {'lon': -73.9763, 'lat': 40.6838}, 'name': 'Atlantic Ave & Fort Greene Pl'},\n",
296-
" {'station_id': 116, 'capacity': 39, 'coords': {'lon': -74.0015, 'lat': 40.7418}, 'name': 'W 17 St & 8 Ave'}\n",
283+
" {\n",
284+
" \"station_id\": 72,\n",
285+
" \"capacity\": 39,\n",
286+
" \"coords\": {\"lon\": -73.9939, \"lat\": 40.7673},\n",
287+
" \"name\": \"W 52 St & 11 Ave\",\n",
288+
" },\n",
289+
" {\n",
290+
" \"station_id\": 79,\n",
291+
" \"capacity\": 33,\n",
292+
" \"coords\": {\"lon\": -74.0067, \"lat\": 40.7191},\n",
293+
" \"name\": \"Franklin St & W Broadway\",\n",
294+
" },\n",
295+
" {\n",
296+
" \"station_id\": 82,\n",
297+
" \"capacity\": 27,\n",
298+
" \"coords\": {\"lon\": -74.0002, \"lat\": 40.7673},\n",
299+
" \"name\": \"St James Pl & Pearl St\",\n",
300+
" },\n",
301+
" {\n",
302+
" \"station_id\": 83,\n",
303+
" \"capacity\": 62,\n",
304+
" \"coords\": {\"lon\": -73.9763, \"lat\": 40.6838},\n",
305+
" \"name\": \"Atlantic Ave & Fort Greene Pl\",\n",
306+
" },\n",
307+
" {\n",
308+
" \"station_id\": 116,\n",
309+
" \"capacity\": 39,\n",
310+
" \"coords\": {\"lon\": -74.0015, \"lat\": 40.7418},\n",
311+
" \"name\": \"W 17 St & 8 Ave\",\n",
312+
" },\n",
297313
"]"
298314
]
299315
},
@@ -321,7 +337,7 @@
321337
"outputs": [],
322338
"source": [
323339
"# Get the name for the first station\n",
324-
"citibike_stations[0]['name']"
340+
"citibike_stations[0][\"name\"]"
325341
]
326342
},
327343
{
@@ -337,7 +353,7 @@
337353
"metadata": {},
338354
"outputs": [],
339355
"source": [
340-
"citibike_stations[0]['coords']"
356+
"citibike_stations[0][\"coords\"]"
341357
]
342358
},
343359
{
@@ -353,7 +369,7 @@
353369
"metadata": {},
354370
"outputs": [],
355371
"source": [
356-
"citibike_stations[0]['coords']['lat']"
372+
"citibike_stations[0][\"coords\"][\"lat\"]"
357373
]
358374
},
359375
{
@@ -403,15 +419,8 @@
403419
"outputs": [],
404420
"source": [
405421
"data = {\n",
406-
" \"Panos\": {\n",
407-
" \"Job\": \"Professor\",\n",
408-
" \"YOB\": \"1976\",\n",
409-
" \"Children\": [\"Gregory\", \"Anna\"]\n",
410-
" },\n",
411-
" \"Joe\": {\n",
412-
" \"Job\": \"Data Scientist\",\n",
413-
" \"YOB\": \"1981\"\n",
414-
" }\n",
422+
" \"Panos\": {\"Job\": \"Professor\", \"YOB\": \"1976\", \"Children\": [\"Gregory\", \"Anna\"]},\n",
423+
" \"Joe\": {\"Job\": \"Data Scientist\", \"YOB\": \"1981\"},\n",
415424
"}"
416425
]
417426
},
@@ -457,7 +466,7 @@
457466
"metadata": {},
458467
"outputs": [],
459468
"source": [
460-
"# Prints the number of people _entries_ in the data. \n",
469+
"# Prints the number of people _entries_ in the data.\n",
461470
"# (Notice that it is much harder to find all the people in the data, eg the children)"
462471
]
463472
},
@@ -501,7 +510,7 @@
501510
{
502511
"cell_type": "markdown",
503512
"metadata": {
504-
"solution2": "shown",
513+
"solution2": "hidden",
505514
"solution2_first": true
506515
},
507516
"source": [
@@ -512,84 +521,84 @@
512521
"cell_type": "code",
513522
"execution_count": null,
514523
"metadata": {
515-
"solution2": "shown"
524+
"solution2": "hidden"
516525
},
517526
"outputs": [],
518527
"source": [
519528
"# Prints the job of Joe\n",
520-
"data['Joe']['Job']"
529+
"data[\"Joe\"][\"Job\"]"
521530
]
522531
},
523532
{
524533
"cell_type": "code",
525534
"execution_count": null,
526535
"metadata": {
527-
"solution2": "shown"
536+
"solution2": "hidden"
528537
},
529538
"outputs": [],
530539
"source": [
531540
"# Prints the year of birth of Panos\n",
532-
"data['Panos']['YOB']"
541+
"data[\"Panos\"][\"YOB\"]"
533542
]
534543
},
535544
{
536545
"cell_type": "code",
537546
"execution_count": null,
538547
"metadata": {
539-
"solution2": "shown"
548+
"solution2": "hidden"
540549
},
541550
"outputs": [],
542551
"source": [
543552
"# Prints the children of Panos\n",
544-
"data['Panos']['Children']"
553+
"data[\"Panos\"][\"Children\"]"
545554
]
546555
},
547556
{
548557
"cell_type": "code",
549558
"execution_count": null,
550559
"metadata": {
551-
"solution2": "shown"
560+
"solution2": "hidden"
552561
},
553562
"outputs": [],
554563
"source": [
555564
"# Prints the second child of Panos\n",
556-
"data['Panos']['Children'][1]"
565+
"data[\"Panos\"][\"Children\"][1]"
557566
]
558567
},
559568
{
560569
"cell_type": "code",
561570
"execution_count": null,
562571
"metadata": {
563-
"solution2": "shown"
572+
"solution2": "hidden"
564573
},
565574
"outputs": [],
566575
"source": [
567576
"# Checks if Maria is in the data\n",
568-
"'Maria' in data.keys()"
577+
"\"Maria\" in data.keys()"
569578
]
570579
},
571580
{
572581
"cell_type": "code",
573582
"execution_count": null,
574583
"metadata": {
575-
"solution2": "shown"
584+
"solution2": "hidden"
576585
},
577586
"outputs": [],
578587
"source": [
579588
"# Checks if Maria is in the data, simpler\n",
580-
"'Maria' in data"
589+
"\"Maria\" in data"
581590
]
582591
},
583592
{
584593
"cell_type": "code",
585594
"execution_count": null,
586595
"metadata": {
587-
"solution2": "shown"
596+
"solution2": "hidden"
588597
},
589598
"outputs": [],
590599
"source": [
591600
"# Checks if Anna is in the data\n",
592-
"'Anna' in data\n",
601+
"\"Anna\" in data\n",
593602
"# Notice that the in command *will not* look into the values\n",
594603
"# We need to use much more complex code to check all the data, beyond the keys"
595604
]
@@ -598,7 +607,7 @@
598607
"cell_type": "code",
599608
"execution_count": null,
600609
"metadata": {
601-
"solution2": "shown"
610+
"solution2": "hidden"
602611
},
603612
"outputs": [],
604613
"source": [
@@ -610,7 +619,7 @@
610619
"cell_type": "code",
611620
"execution_count": null,
612621
"metadata": {
613-
"solution2": "shown"
622+
"solution2": "hidden"
614623
},
615624
"outputs": [],
616625
"source": [
@@ -622,7 +631,7 @@
622631
"cell_type": "code",
623632
"execution_count": null,
624633
"metadata": {
625-
"solution2": "shown"
634+
"solution2": "hidden"
626635
},
627636
"outputs": [],
628637
"source": [
@@ -648,7 +657,7 @@
648657
"name": "python",
649658
"nbconvert_exporter": "python",
650659
"pygments_lexer": "ipython3",
651-
"version": "3.5.2"
660+
"version": "3.8.2"
652661
}
653662
},
654663
"nbformat": 4,

0 commit comments

Comments
 (0)