# -*- coding: utf-8 -*- """ Created on Thu Sep 21 12:24:37 2017 @author: Douzi """ import pandas as pd # 用户信息 unames = [‘user_id‘, ‘gender‘, ‘age‘, ‘occupation‘, ‘zip‘] users = pd.read_table(‘ch02/movielens/users.dat‘, sep=‘::‘, header=None, names=unames, engine=‘python‘) # 电影排名 rnames = [‘user_id‘, ‘movie_id‘, ‘rating‘, ‘timestamp‘] ratings = pd.read_table(‘ch02/movielens/ratings.dat‘, sep=‘::‘, header=None, names=rnames,engine=‘python‘) # 电影信息 mnames = [‘movie_id‘, ‘title‘, ‘genres‘] movies = pd.read_table(‘ch02/movielens/movies.dat‘, sep=‘::‘, header=None, names=mnames, engine=‘python‘) users[:5] Out[113]: user_id gender age occupation zip 0 1 F 1 10 48067 1 2 M 56 16 70072 2 3 M 25 15 55117 3 4 M 45 7 02460 4 5 M 25 20 55455 ratings[:5] Out[114]: user_id movie_id rating timestamp 0 1 1193 5 978300760 1 1 661 3 978302109 2 1 914 3 978301968 3 1 3408 4 978300275 4 1 2355 5 978824291 movies[:5] Out[115]: movie_id title genres 0 1 Toy Story (1995) Animation|Children‘s|Comedy 1 2 Jumanji (1995) Adventure|Children‘s|Fantasy 2 3 Grumpier Old Men (1995) Comedy|Romance 3 4 Waiting to Exhale (1995) Comedy|Drama 4 5 Father of the Bride Part II (1995) Comedy
时间: 2024-11-07 23:24:51