Spaces:
Runtime error
Runtime error
tobiasaurer
commited on
Commit
•
65d4df9
1
Parent(s):
bb0c663
bugfix
Browse files
pages/1 - Popularity-Based Recommender.py
CHANGED
@@ -56,14 +56,13 @@ def get_popular_recommendations_streaming(n, genres, country, url, headers):
|
|
56 |
[lambda df: df["genres"].str.contains(genres, regex=True)]
|
57 |
.sort_values('combined_rating', ascending=False)
|
58 |
.head(n)
|
59 |
-
[['title', 'avg_rating', 'genres']]
|
60 |
)
|
61 |
# merge recommendations with links df to get imdbIds for the API calls
|
62 |
recommendations_ids = (
|
63 |
recommendations
|
64 |
-
.merge(movies, how = 'left', on = 'title')
|
65 |
.merge(links, how = 'left', on = 'movieId')
|
66 |
-
[['title', 'genres', 'imdbId']]
|
67 |
)
|
68 |
recommendations_ids['imdbId'] = 'tt0' + recommendations_ids['imdbId'].astype('str')
|
69 |
imdb_ids = list(recommendations_ids['imdbId'])
|
@@ -82,7 +81,7 @@ def get_popular_recommendations_streaming(n, genres, country, url, headers):
|
|
82 |
for streaming_service in streaming_info['streamingInfo']:
|
83 |
recommendations_ids.loc[recommendations_ids['imdbId'] == id, 'Streaming Availability'] += f"{streaming_service}: {streaming_info['streamingInfo'][streaming_service][country]['link']} \n"
|
84 |
|
85 |
-
|
86 |
|
87 |
def transform_genre_to_regex(genres):
|
88 |
regex = ""
|
|
|
56 |
[lambda df: df["genres"].str.contains(genres, regex=True)]
|
57 |
.sort_values('combined_rating', ascending=False)
|
58 |
.head(n)
|
59 |
+
[['title', 'avg_rating', 'genres', 'movieId']]
|
60 |
)
|
61 |
# merge recommendations with links df to get imdbIds for the API calls
|
62 |
recommendations_ids = (
|
63 |
recommendations
|
|
|
64 |
.merge(links, how = 'left', on = 'movieId')
|
65 |
+
# [['title', 'genres', 'imdbId']]
|
66 |
)
|
67 |
recommendations_ids['imdbId'] = 'tt0' + recommendations_ids['imdbId'].astype('str')
|
68 |
imdb_ids = list(recommendations_ids['imdbId'])
|
|
|
81 |
for streaming_service in streaming_info['streamingInfo']:
|
82 |
recommendations_ids.loc[recommendations_ids['imdbId'] == id, 'Streaming Availability'] += f"{streaming_service}: {streaming_info['streamingInfo'][streaming_service][country]['link']} \n"
|
83 |
|
84 |
+
return recommendations_ids[['title', 'genres', 'Streaming Availability']]
|
85 |
|
86 |
def transform_genre_to_regex(genres):
|
87 |
regex = ""
|