-1

I was trying tofunction for recommender system. The following is my code

def recommend(movie_title, min_count):
    print("for movie({})".format(movie_title))
    print("Top 10 movies recommended are")
    i=(df["title"]== movie_title[0])
    target=final_movie_table[i]
    similar_target=final_movie_table.corrwith(target)
    corr_target=pd.DataFrame(similar_target, columns = ['Correlation'])
    corr_target.dropna(inplace = True)
    corr_target = corr_target.sort_values('Correlation', ascending = False)
    corr_target.index = corr_target.index.map(int)
    corr_target=corr_target.join(mean)[["Correlation", "title", "rating", "rating count"]]
    print(corr_target[corr_target["rating count"]> min_count][:10].to_string(index=False))

The following is my error:

UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  """
Empty DataFrame
Columns: [Correlation, title, rating, rating count]
Index: []

How can I resolve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    This question is not properly posed because it is not replicable in any way. We can only watch your code and figure out what's wrong with it. – Luca Massaron Nov 22 '20 at 00:19

1 Answers1

1

Probably for some reason you have a mismatch between the df and final_movie_table dataframes: they may be of different length.

Please see this answer for a general explanation about this kind of error: Boolean Series key will be reindexed to match DataFrame index

As a check, just try:

print(len(df), len(final_movie_table ))

the lengths should be different.

Luca Massaron
  • 1,734
  • 18
  • 25