Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. df = pd.read_csv('ratings.csv', sep=',')
  2. df_id = pd.read_csv('links.csv', sep=',')
  3. df = pd.merge(df, df_id, on=['movieId'])
  4.  
  5. rating_matrix = np.zeros((df.userId.unique().shape[0], max(df.movieId)))
  6. for row in df.itertuples():
  7. rating_matrix[row[1]-1, row[2]-1] = row[3]
  8. rating_matrix = rating_matrix[:,:9000]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement