Skip to content

Commit 2599c14

Browse files
committed
update error related contents
1 parent 3653e23 commit 2599c14

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

modules/module1/slides/module1_29.qmd

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,19 @@ Now we can use `.value_counts()` on this `mfr_column` variable to reference it,
7777
---
7878

7979
```{python}
80-
mfr_col_wrong = cereal[['mfr']]
81-
mfr_col_wrong
80+
mfr_col_dataframe = cereal[['mfr']]
81+
mfr_col_dataframe
8282
```
8383

8484
<br>
8585

86-
```python
87-
mfr_col_wrong.value_counts()
86+
```{python}
87+
mfr_col_dataframe.value_counts()
8888
```
8989

90-
```out
91-
AttributeError: 'DataFrame' object has no attribute 'value_counts'
92-
93-
Detailed traceback:
94-
File "<string>", line 1, in <module>
95-
File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 5274, in __getattr__
96-
return object.__getattribute__(self, name)
97-
```
9890

9991
:::{.notes}
100-
If we did instead use double square brackets with `pd.value_counts()`, we would get an error. So it is important to take care and remember when you are using `value_counts()`, you only use one set of square brackets.
92+
`value_counts()` can also be called on a DataFrame to count unique rows.
10193
:::
10294

10395
---

modules/module2/slides/module2_20.qmd

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,16 @@ cereal[cereal['mfr'] == 'Q', 'mfr'] = 'Quaker'
195195
```
196196

197197
```out
198-
TypeError: 'Series' objects are mutable, thus they cannot be hashed
198+
TypeError: unhashable type: 'Series'
199199
200200
Detailed traceback:
201201
File "<string>", line 1, in <module>
202-
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 2938, in __setitem__
202+
File "/usr/local/lib/python3.12/site-packages/pandas/core/frame.py", line 4311, in __setitem__
203203
self._set_item(key, value)
204-
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3000, in _set_item
205-
value = self._sanitize_column(key, value)
206-
File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3666, in _sanitize_column
207-
if broadcast and key in self.columns and value.ndim == 1:
208-
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3899, in __contains__
204+
File "/usr/local/lib/python3.12/site-packages/pandas/core/frame.py", line 4527, in _set_item
205+
key in self.columns
206+
File "/usr/local/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 5358, in __contains__
209207
hash(key)
210-
File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 1799, in __hash__
211-
f"{repr(type(self).__name__)} objects are mutable, "
212208
```
213209

214210

0 commit comments

Comments
 (0)