Nike Cage 675
Nike Cage 675

Reputation: 71

TypeError: category dtype does not support aggregation 'mean' for Movies

I used these codes using the groupby() function to find the top averages, budgets, revenue etc. for movies as part of my Exploratory Data Analysis:

movies = df.groupby('Title')

movies.mean().sort_values(by='TMDB Vote Average', ascending=False).head()

This worked on older versions of Anaconda or Jupyter Notebook but I cannot understand why it is not working on the latest version of Anaconda or Jupyter Notebook when I upgraded towards this system.

Does anyone in the community know how I can rectify this problem? Thank you for your time.

Upvotes: 0

Views: 56

Answers (1)

user23642684
user23642684

Reputation: 3

If your values are non-numeric (ie. 5 vs "5"), then print(df.dtypes) might be able to help. You might also need df['TMDB Vote Average'] = pd.to_numeric(df['TMDB Vote Average'], errors='coerce').

Upvotes: 0

Related Questions