Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to create MovieLens data as pandas.DataFrame
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