# -*- coding: utf-8 -*-
"""
Created on Tue Oct 16 17:12:28 2018
@author: fengjuan
"""
import pandas as pd
#将各个表分别读到pandas Dataframe中
unames=['user_id','gender','age','occupation','zip']
users=pd.read_table('E:/python/ml-1m/users.dat',sep='::',header=None,names=unames)
rnames=['user_id','movie_id','rating','names=rnames']
ratings=pd.read_table('E:/python/ml-1m/ratings.dat',sep='::',header=None,names=rnames)
mnames=['movie_id','title','genres']
movies=pd.read_table('E:/python/ml-1m/movies.dat',sep='::',header=None,names=mnames)
print(users[:5])
'''结果:
#print(users[:5])
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
user_id movie_id rating names=rnames
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'''
print(ratings[:5])
'''结果:
user_id movie_id rating names=rnames
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'''
print(movies[:5])
'''结果
movie_id ...