swcarpentry / python-novice-gapminder

Plotting and Programming in Python
http://swcarpentry.github.io/python-novice-gapminder/
Other
163 stars 428 forks source link

Solution to "Comparing Data" (Ep. 14) throws deprecation warning #580

Open alex-ball opened 2 years ago

alex-ball commented 2 years ago

As of Pandas 1.3.0 (July 2, 2021), the solution to "Comparing Data" in episode 14 throws the same warning several times.

https://github.com/swcarpentry/python-novice-gapminder/blob/f675de6edcefc46f3a655d3c92c9fb9e28222983/_episodes/14-looping-data-sets.md#L169-L176

FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.

The problem is in line 176, and the quickest fix is simply to flip the toggle the other way:

    dataframe.mean(numeric_only=True).plot(ax=ax, label=region)

But this is a bit of extra cognitive load. Should we just tell learners about this in advance, or is there an alternative solution that avoids the issue? Or should the task itself be adjusted?