I tried calculating the mean as seen from a YT video. It does not calculate mean for my code but does it for the youtuber/mentor.
The code goes:
books = pd.read_csv(‘Books2.csv’, on_bad_lines=‘skip’, low_memory=False)
users = pd.read_csv(‘Users.csv’)
ratings = pd.read_csv(‘Ratings.csv’)
…
…
…
books_rated = books.merge(ratings, on=‘ISBN’).drop(columns=[‘User-ID’, ‘Year-Of-Publication’,‘Image-URL-L’,‘Image-URL-S’])
books_rated.isnull().sum().dropna()
…
…
…
books_rated = books_rated.groupby(‘Book-Title’).count()[‘Book-Rating’].reset_index()
books_rated_avg = books_rated.groupby(‘Book-Title’)[‘Book-Rating’].mean().reset_index()
books_rated_avg.rename(columns={‘Book-Rating’: ‘avg-rating’},inplace=True)
The bold line is where i tried to take the mean of Book-Rating for each group of ‘Book-Title’.
On printing the ‘books_rated_avg’ it is giving me the result same as books_rated. Only the column name got changed.