Skip to content

Commit e4fb574

Browse files
committed
Fix path to surveys.csv (closes #13).
Move traceback in indexing module to Markdown cell (closes #12). Remove --allow-errors from build.sh since we now every cell should execute without traceback.
1 parent feda0e0 commit e4fb574

File tree

11 files changed

+477
-1314
lines changed

11 files changed

+477
-1314
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To add or modify content, edit the notebooks in
77

88
## Quick start
99
```bash
10-
# install pipenv to ~/.local/bin/pipenv
10+
# Install pipenv to ~/.local/bin/pipenv
1111
pip install --user pipenv
1212

1313
git clone https://github.com/MonashDataFluency/python-workshop-base.git

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ TEMPLATE_DIR="workshops/docs/modules/notebooks/nbconvert_templates"
1010
# Markdown example cell so that code is displayed by not executed.
1111

1212
# ggplot/plotnine cells are sometimes slow, so we increase the default timeout
13-
EXECUTE="--execute --allow-errors --ExecutePreprocessor.timeout=240"
14-
# EXECUTE="--execute --ExecutePreprocessor.timeout=240"
13+
# EXECUTE="--execute --allow-errors --ExecutePreprocessor.timeout=240"
14+
EXECUTE="--execute --ExecutePreprocessor.timeout=240"
1515

1616
generate_html='no'
1717
generate_instructor_notes='no'

workshops/docs/modules/indexing.md

Lines changed: 73 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ In this lesson, we will explore **ways to access different parts of the data** i
7373
<pre class="output">
7474
<div class="output_label">output</div>
7575
<code class="text">
76-
Requirement already satisfied: pandas in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (0.23.0)
77-
Requirement already satisfied: matplotlib in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (2.2.2)
78-
Requirement already satisfied: numpy>=1.9.0 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (1.14.3)
79-
Requirement already satisfied: python-dateutil>=2.5.0 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (2.7.3)
80-
Requirement already satisfied: pytz>=2011k in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (2018.4)
81-
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (2.2.0)
82-
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (1.0.1)
83-
Requirement already satisfied: cycler>=0.10 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (0.10.0)
84-
Requirement already satisfied: six>=1.10 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (1.11.0)
85-
Requirement already satisfied: setuptools in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (39.2.0)
76+
Requirement already satisfied: pandas in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (0.23.0)
77+
Requirement already satisfied: matplotlib in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (2.2.2)
78+
Requirement already satisfied: python-dateutil>=2.5.0 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (2.7.3)
79+
Requirement already satisfied: pytz>=2011k in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (2018.4)
80+
Requirement already satisfied: numpy>=1.9.0 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (1.14.3)
81+
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (2.2.0)
82+
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (1.0.1)
83+
Requirement already satisfied: six>=1.10 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (1.11.0)
84+
Requirement already satisfied: cycler>=0.10 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (0.10.0)
85+
Requirement already satisfied: setuptools in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (39.1.0)
8686

8787
</code>
8888
</pre>
@@ -107,7 +107,7 @@ We will continue to use the surveys dataset that we worked with in the last less
107107
import pandas as pd
108108

109109
# Read in the survey CSV
110-
surveys_df = pd.read_csv("data/surveys.csv")
110+
surveys_df = pd.read_csv("surveys.csv")
111111
```
112112

113113

@@ -294,105 +294,90 @@ surveys_df[['species_id', 'site_id']].head()
294294

295295

296296

297-
```python
297+
What happens if you ask for a column that doesn't exist?
298298

299-
# What happens if you ask for a column that doesn't exist?
299+
```python
300300
surveys_df['speciess']
301-
302-
303301
```
304302

303+
Outputs:
305304

306-
---------------------------------------------------------------------------
307-
308-
KeyError Traceback (most recent call last)
309-
310-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
311-
3062 try:
312-
-> 3063 return self._engine.get_loc(key)
313-
3064 except KeyError:
314-
315-
316-
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
317-
318-
319-
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
320-
321-
322-
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
323305

324306

325-
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
326307

327308

328-
KeyError: 'speciess'
329-
330-
331-
During handling of the above exception, another exception occurred:
332-
333-
334-
KeyError Traceback (most recent call last)
335-
336-
<ipython-input-7-8c68e7647ac0> in <module>()
337-
1
338-
2 # What happens if you ask for a column that doesn't exist?
339-
----> 3 surveys_df['speciess']
340-
341-
342-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
343-
2683 return self._getitem_multilevel(key)
344-
2684 else:
345-
-> 2685 return self._getitem_column(key)
346-
2686
347-
2687 def _getitem_column(self, key):
348-
349-
350-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
351-
2690 # get column
352-
2691 if self.columns.is_unique:
353-
-> 2692 return self._get_item_cache(key)
354-
2693
355-
2694 # duplicate columns & possible reduce dimensionality
309+
```python
310+
---------------------------------------------------------------------------
311+
KeyError Traceback (most recent call last)
312+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
313+
2392 try:
314+
-> 2393 return self._engine.get_loc(key)
315+
2394 except KeyError:
356316

317+
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5239)()
357318

358-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
359-
2484 res = cache.get(item)
360-
2485 if res is None:
361-
-> 2486 values = self._data.get(item)
362-
2487 res = self._box_item_values(item, values)
363-
2488 cache[item] = res
319+
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5085)()
364320

321+
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20405)()
365322

366-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
367-
4113
368-
4114 if not isna(item):
369-
-> 4115 loc = self.items.get_loc(item)
370-
4116 else:
371-
4117 indexer = np.arange(len(self.items))[isna(self.items)]
323+
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20359)()
372324

325+
KeyError: 'speciess'
373326

374-
~/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
375-
3063 return self._engine.get_loc(key)
376-
3064 except KeyError:
377-
-> 3065 return self._engine.get_loc(self._maybe_cast_indexer(key))
378-
3066
379-
3067 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
327+
During handling of the above exception, another exception occurred:
380328

329+
KeyError Traceback (most recent call last)
330+
<ipython-input-7-7d65fa0158b8> in <module>()
331+
1
332+
2 # What happens if you ask for a column that doesn't exist?
333+
----> 3 surveys_df['speciess']
334+
4
381335

382-
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
336+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
337+
2060 return self._getitem_multilevel(key)
338+
2061 else:
339+
-> 2062 return self._getitem_column(key)
340+
2063
341+
2064 def _getitem_column(self, key):
383342

343+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
344+
2067 # get column
345+
2068 if self.columns.is_unique:
346+
-> 2069 return self._get_item_cache(key)
347+
2070
348+
2071 # duplicate columns & possible reduce dimensionality
384349

385-
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
350+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
351+
1532 res = cache.get(item)
352+
1533 if res is None:
353+
-> 1534 values = self._data.get(item)
354+
1535 res = self._box_item_values(item, values)
355+
1536 cache[item] = res
386356

357+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
358+
3588
359+
3589 if not isnull(item):
360+
-> 3590 loc = self.items.get_loc(item)
361+
3591 else:
362+
3592 indexer = np.arange(len(self.items))[isnull(self.items)]
387363

388-
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
364+
/Applications/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
365+
2393 return self._engine.get_loc(key)
366+
2394 except KeyError:
367+
-> 2395 return self._engine.get_loc(self._maybe_cast_indexer(key))
368+
2396
369+
2397 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
389370

371+
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5239)()
390372

391-
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
373+
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5085)()
392374

375+
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20405)()
393376

394-
KeyError: 'speciess'
377+
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20359)()
395378

379+
KeyError: 'speciess'
380+
```
396381

397382

398383

@@ -877,7 +862,7 @@ the original data CSV file.
877862

878863

879864
```python
880-
surveys_df = pd.read_csv("data/surveys.csv")
865+
surveys_df = pd.read_csv("surveys.csv")
881866
```
882867

883868

@@ -1084,7 +1069,7 @@ surveys_df.loc[[0, 10, 35549], :]
10841069
<pre class="output">
10851070
<div class="output_label">output</div>
10861071
<code class="text">
1087-
/Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages/pandas/core/indexing.py:1472: FutureWarning:
1072+
/Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages/pandas/core/indexing.py:1472: FutureWarning:
10881073
Passing list-likes to .loc or [] with any missing label will raise
10891074
KeyError in the future, you can use .reindex() as an alternative.
10901075

@@ -5150,14 +5135,14 @@ stack_selection.plot(kind='bar', stacked=True)
51505135
<pre class="output">
51515136
<div style="text-align: right; margin: -1em; padding: 0;"><span style="font-size: 0.5em; color: grey">output</span></div>
51525137
<code class="text">
5153-
<matplotlib.axes._subplots.AxesSubplot at 0x10eccdc18>
5138+
<matplotlib.axes._subplots.AxesSubplot at 0x1083a6470>
51545139
</code>
51555140
</pre>
51565141

51575142

51585143

51595144

5160-
![png](indexing_files/indexing_73_1.png)
5145+
![png](indexing_files/indexing_74_1.png)
51615146

51625147

51635148

workshops/docs/modules/missing_values.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ Before we start, lets make sure the Pandas and matplotlib packages are **install
6464
<pre class="output">
6565
<div class="output_label">output</div>
6666
<code class="text">
67-
Requirement already satisfied: pandas in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (0.23.0)
68-
Requirement already satisfied: matplotlib in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (2.2.2)
69-
Requirement already satisfied: pytz>=2011k in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (2018.4)
70-
Requirement already satisfied: python-dateutil>=2.5.0 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (2.7.3)
71-
Requirement already satisfied: numpy>=1.9.0 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from pandas) (1.14.3)
72-
Requirement already satisfied: six>=1.10 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (1.11.0)
73-
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (2.2.0)
74-
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (1.0.1)
75-
Requirement already satisfied: cycler>=0.10 in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from matplotlib) (0.10.0)
76-
Requirement already satisfied: setuptools in /Users/asha0035/.local/share/virtualenvs/python-workshop-base-LFzz33nP/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (39.2.0)
67+
Requirement already satisfied: pandas in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (0.23.0)
68+
Requirement already satisfied: matplotlib in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (2.2.2)
69+
Requirement already satisfied: numpy>=1.9.0 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (1.14.3)
70+
Requirement already satisfied: pytz>=2011k in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (2018.4)
71+
Requirement already satisfied: python-dateutil>=2.5.0 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from pandas) (2.7.3)
72+
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (2.2.0)
73+
Requirement already satisfied: kiwisolver>=1.0.1 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (1.0.1)
74+
Requirement already satisfied: cycler>=0.10 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (0.10.0)
75+
Requirement already satisfied: six>=1.10 in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from matplotlib) (1.11.0)
76+
Requirement already satisfied: setuptools in /Users/perry/.virtualenvs/python-workshop-base-ufuVBSbV/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib) (39.1.0)
7777

7878
</code>
7979
</pre>
@@ -100,7 +100,7 @@ Now again import `surveys.csv` dataset into our notebook as we did in previous l
100100

101101

102102
```python
103-
surveys_df = pd.read_csv("data/surveys.csv")
103+
surveys_df = pd.read_csv("surveys.csv")
104104
```
105105

106106

0 commit comments

Comments
 (0)