effective_pandas_book
effective_pandas_book copied to clipboard
[Chapter 27] Couple of possible improvements
Hi Matt, thanks for your book, really enjoying it. I'd suggest a couple of changes in chapter 27:
- Within the description of the parameters of method
pandas.DataFrame.groupby()
at page 322, I'd change the specification ofdropna
. Indeed, this works differently than the same parameter inpandas.DataFrame.pivot_table()
or in functionpandas.crosstab()
, where it applies to values (and therefore << [...]dropna=False
will keep columns that have no values >>). Instead, inpandas.DataFrame.groupby()
dropna
applies to group keys (the description above - which is specified in the book - is no longer valid). For this reason, the DataFrame at page 305 should have 8 columns, rather than 4. - At pages 313-314 of the book, per column aggregations are not applied on numeric columns only, which we instead may possibly get by typing
jb2.groupby('country_live')[[col for col in jb2.select_dtypes('number').columns]].agg(['min', 'max'])
.