-1
for userID, curUser in user_Group:

    # Create a temp that stores every movie's rating
    temp = [0]*len(movies_df)

    # For each movie in curUser's movie list
    for num, movie in curUser.iterrows():

        # Divide the rating by 5 and store it
        temp[movie['List Index']] = movie['Rating']/5.0

    # Add the list of ratings into the training list
    trX.append(temp)

This is portion of my code for a movie recommendation system and I'm getting the list indices must be integers or slices, not numpy.float64 error. Why is that happening?

jared
  • 4,165
  • 1
  • 8
  • 31
  • Please provide a reproducible example of the input DataFrame and the matching expected output. – mozway Aug 04 '23 at 07:43
  • from the full error message determine which line is the problem, and within that which variable is a list, and which index is a float. None of that is obvious from just reading that small bit of code. – hpaulj Aug 04 '23 at 14:33
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 04 '23 at 17:27

0 Answers0