Created
July 6, 2016 13:36
-
-
Save anonymous/90b43a337e2d64db375098ab17965bb3 to your computer and use it in GitHub Desktop.
How to create MovieLens data as pandas.DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
movielens = pd.DataFrame.from_csv( | |
path='http://files.grouplens.org/datasets/movielens/ml-100k/u.data', | |
sep='\t', header=None, index_col=None) | |
_ITEM_FEATURES = """ | |
item_id | movie title | release date | | |
video release date | IMDb URL | unknown | | |
Action | Adventure | Animation | | |
Children | Comedy | Crime | | |
Documentary | Drama | Fantasy | | |
Film-Noir | Horror | Musical | | |
Mystery | Romance | Sci-Fi | | |
Thriller | War | Western""" | |
item_features = map(lambda f: f.replace('\n', '').replace(' ', '-').lower(), _ITEM_FEATURES.split(' | ')) | |
movielens.columns = item_features |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment