I have a movie recommender system I have been working on and currently it is printing two different sets of output because I have two different types of recommendation engines. Code is like this:
while True:
user_input3 = input('Please enter movie title: ')
if user_input3 == 'done':
break
try:
print(' ')
print(get_input_movie(user_input3))
print(get_input_movie(user_input3, cosine_sim1))
# print(get_input_movie(user_input3), get_input_movie(user_input3,cosine_sim1))
print(' ')
except KeyError or ValueError:
print('Check your movie title spelling, capitalization and try again.')
print(' ')
continue
And the example output looks like this.
Please enter movie title: Casino
34652 The Under-Gifted
28155 The Plague
12738 The Incredible Hulk
41823 The Ugly Duckling
44976 12 Feet Deep
Name: Title, dtype: object
1177 GoodFellas
1192 Raging Bull
25900 The Big Shave
109 Taxi Driver
7617 Mean Streets
Name: Title, dtype: object
How can I make it so it combines the answers? So it looks like this:
Please enter movie title: Casino
34652 The Under-Gifted
28155 The Plague
12738 The Incredible Hulk
41823 The Ugly Duckling
44976 12 Feet Deep
1177 GoodFellas
1192 Raging Bull
25900 The Big Shave
109 Taxi Driver
7617 Mean Streets
If the return type of get_input_movie()
is a Pandas DataFrame or a Pandas Series, you can try:
Replace the following 2 lines:
print(get_input_movie(user_input3))
print(get_input_movie(user_input3, cosine_sim1))
by using Series.append()
or DataFrame.append()
as follows:
print(get_input_movie(user_input3).append(get_input_movie(user_input3, cosine_sim1)))
Here, we appended the results of the 2 function calls before printing it. The combined results will be printed then.