Skip to content

Instantly share code, notes, and snippets.

Created July 6, 2016 13:36
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 anonymous/90b43a337e2d64db375098ab17965bb3 to your computer and use it in GitHub Desktop.
Save anonymous/90b43a337e2d64db375098ab17965bb3 to your computer and use it in GitHub Desktop.
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