Open
Description
I have been following the code in your book in jupyter notebook.
There is several places where the code leads to errors. The errors also show up in the github version of the code.
For example:
In the your notebook Chapters 16-30 (page 302 in the physical book)
input 106 and 107 lead to errors. Have they been corrected?
(jb2
.pivot_table(index='country_live', columns='employment_status',
values='age', aggfunc='mean')
)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-c65017e0f276> in <module>
1 # run code
----> 2 (jb2
3 .pivot_table(index='country_live', columns='employment_status',
4 values='age', aggfunc='mean')
5 )
~/envs/menv/lib/python3.8/site-packages/pandas/core/frame.py in pivot_table(self, values, index, columns, aggfunc, fill_value, margins, dropna, margins_name, observed, sort)
8036 from pandas.core.reshape.pivot import pivot_table
8037
-> 8038 return pivot_table(
8039 self,
8040 values=values,
~/envs/menv/lib/python3.8/site-packages/pandas/core/reshape/pivot.py in pivot_table(data, values, index, columns, aggfunc, fill_value, margins, dropna, margins_name, observed, sort)
93 return table.__finalize__(data, method="pivot_table")
94
---> 95 table = __internal_pivot_table(
96 data,
97 values,
~/envs/menv/lib/python3.8/site-packages/pandas/core/reshape/pivot.py in __internal_pivot_table(data, values, index, columns, aggfunc, fill_value, margins, dropna, margins_name, observed, sort)
185 # agged.columns is a MultiIndex and 'v' is indexing only
186 # on its first level.
--> 187 agged[v] = maybe_downcast_to_dtype(agged[v], data[v].dtype)
188
189 table = agged
~/envs/menv/lib/python3.8/site-packages/pandas/core/dtypes/cast.py in maybe_downcast_to_dtype(result, dtype)
275 if not isinstance(dtype, np.dtype):
276 # enforce our signature annotation
--> 277 raise TypeError(dtype) # pragma: no cover
278
279 converted = maybe_downcast_numeric(result, dtype, do_round)
TypeError: Int64
Metadata
Metadata
Assignees
Labels
No labels