July 2017
Beginner to intermediate
420 pages
10h 56m
English
The first thing we're going to do is import the u.data file as part of the MovieLens dataset, and that is a tab-delimited file that contains every rating in the dataset.
import pandas as pd
r_cols = ['user_id', 'movie_id', 'rating']
ratings = pd.read_csv('e:/sundog-consult/packt/datascience/ml-100k/u.data', sep='\\t', names=r_cols, usecols=range(3))
Note that you'll need to add the path here to where you stored the downloaded MovieLens files on your computer. So, the way that this works is even though we're calling read_csv on Pandas, we can specify a different separator than a comma. In this case, it's a tab.
We're basically saying take the first three columns in the u.data file, and import it into a new DataFrame, ...
Read now
Unlock full access