Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alex-ball opened this issue Dec 23, 2021 · 0 comments
Open

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

alex-ball opened this issue Dec 23, 2021 · 0 comments

Comments

@alex-ball
Copy link
Contributor

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

> > for filename in glob.glob('data/gapminder_gdp*.csv'):
> > dataframe = pd.read_csv(filename)
> > # extract <region> from the filename, expected to be in the format 'data/gapminder_gdp_<region>.csv'.
> > # we will split the string using the split method and `_` as our separator,
> > # retrieve the last string in the list that split returns (`<region>.csv`),
> > # and then remove the `.csv` extension from that string.
> > region = filename.split('_')[-1][:-4]
> > dataframe.mean().plot(ax=ax, label=region)

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?

tobyhodges pushed a commit that referenced this issue Apr 17, 2023
Will be useful for HPC-Carpentry lessons, GPU programming lesson as well as Julia lessons which are currently in the incubator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant