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

Fix TypeError in Step 6 by adding numeric_only=True to groupby.mean() #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Utkarsh-Karambhe
Copy link

Issue

In 03_Grouping/Alcohol_Consumption/Exercise_with_solutions.ipynb, Step 6 (drinks.groupby('continent').mean()) raises a TypeError in modern pandas versions (e.g., 2.x) due to attempting to compute the mean of the non-numeric country column.

Fix

Updated the code to drinks.groupby('continent').mean(numeric_only=True) to exclude non-numeric columns, ensuring compatibility with pandas 2.x.

Impact

This fixes the error and aligns the solution with current pandas behavior, improving the exercise for learners.

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

Successfully merging this pull request may close these issues.

1 participant