Skip to content

Instantly share code, notes, and snippets.

@Wann-Jiun
Created January 20, 2017 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wann-Jiun/d4d6c03d0df4928b8b2320023465dca2 to your computer and use it in GitHub Desktop.
Save Wann-Jiun/d4d6c03d0df4928b8b2320023465dca2 to your computer and use it in GitHub Desktop.
df = pd.read_csv('ratings.csv', sep=',')
df_id = pd.read_csv('links.csv', sep=',')
df = pd.merge(df, df_id, on=['movieId'])
rating_matrix = np.zeros((df.userId.unique().shape[0], max(df.movieId)))
for row in df.itertuples():
rating_matrix[row[1]-1, row[2]-1] = row[3]
rating_matrix = rating_matrix[:,:9000]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment