effective_pandas_book icon indicating copy to clipboard operation
effective_pandas_book copied to clipboard

[Chapter 27] Couple of possible improvements

Open AlessandroMiola opened this issue 2 years ago • 0 comments

Hi Matt, thanks for your book, really enjoying it. I'd suggest a couple of changes in chapter 27:

  1. Within the description of the parameters of method pandas.DataFrame.groupby() at page 322, I'd change the specification of dropna. Indeed, this works differently than the same parameter in pandas.DataFrame.pivot_table() or in function pandas.crosstab(), where it applies to values (and therefore << [...] dropna=False will keep columns that have no values >>). Instead, in pandas.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.
  2. 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']).

AlessandroMiola avatar Oct 29 '22 21:10 AlessandroMiola