Created
September 29, 2019 10:27
-
-
Save dradecic/7a65cac23c59c8206417ec26a6411641 to your computer and use it in GitHub Desktop.
recommender1_5_rating_by_genre
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
values = defaultdict(list) | |
for ind, row in data.iterrows(): | |
for genre in row['genres'].split('|'): | |
values[genre].append(row['rating']) | |
genre_lst, rating_lst = [], [] | |
for key, item in values.items(): | |
if key not in [0, 1]: | |
genre_lst.append(key) | |
rating_lst.append(np.mean(item)) | |
genres_with_ratings = pd.DataFrame([genre_lst, rating_lst]).T | |
genres_with_ratings.columns = ['Genre', 'Mean_Rating'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment