import pandas as pd
#读取用户数据表,并指定列名
userColumnsNames = ['user_id','gender','age','occupation','zip']
user = pd.read_table('E:\python\pythonDataAnalysis\pydata-book-master\ch02\movielens\users.dat',sep='::',header=None,names=userColumnsNames)
#读取评分数据表,并指定列名
rNames = ['user_id','movie_id','rating','timestamp']
ratings = pd.read_table(r'E:\python\pythonDataAnalysis\pydata-book-master\ch02\movielens\ratings.dat',sep='::',header=None,names=rNames)
#读取评分数据表,并指定列名
moviesNames = ['movie_id','title','genres']
movies = pd.read_table('E:\python\pythonDataAnalysis\pydata-book-master\ch02\movielens\movies.dat',sep='::',header=None,names=moviesNames)
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:5: ParserWarning: Falling back tothe'python' engine because the'c' engine does not support regex separators (separators > 1charand different from'\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:9: ParserWarning: Falling back tothe'python' engine because the'c' engine does not support regex separators (separators > 1charand different from'\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:13: ParserWarning: Falling back tothe'python' engine because the'c' engine does not support regex separators (separators > 1charand different from'\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
Index([u''burbs, The (1989)', u'10 Things I Hate About You (1999)',
u'101 Dalmatians (1961)', u'101 Dalmatians (1996)',
u'12 Angry Men (1957)'],
dtype='object', name=u'title')
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:1: FutureWarning: by argument to sort_index is deprecated, pls use .sort_values(by=...)
if __name__ == '__main__':
gender
F
M
title
Close Shave, A (1995)
4.644444
4.473795
Wrong Trousers, The (1993)
4.588235
4.478261
Sunset Blvd. (a.k.a. Sunset Boulevard) (1950)
4.572650
4.464589
Wallace & Gromit: The Best of Aardman Animation (1996)
title
'burbs, The (1989) 0.16860710 Things I Hate About You (1999) -0.334586101 Dalmatians (1961) -0.291444101 Dalmatians (1996) -0.32878512 Angry Men (1957) 0.14402413th Warrior, The (1999) 0.0560002 Days inthe Valley (1996) -0.24407620,000 Leagues Under the Sea (1954) 0.0391022001: A Space Odyssey (1968) 0.3041562010 (1984) -0.033097
Name: diff, dtype: float64
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:1: FutureWarning: by argument to sort_index is deprecated, pls use .sort_values(by=...)
if __name__ == '__main__':
<class 'pandas.core.series.Series'>
title
$1,000,000 Duck (1971) 1.092563
'Night Mother (1986) 1.118636
'Til There Was You (1997) 1.020159
'burbs, The (1989) 1.107760
...And Justice for All (1979) 0.878110
Name: rating, dtype: float64
C:\Program Files\anaconda\lib\site-packages\ipykernel\__main__.py:1: FutureWarning: order is deprecated, use sort_values(...)
if __name__ == '__main__':
title
Foreign Student (1994) 2.828427
Criminal Lovers (Les Amants Criminels) (1999) 2.309401
Identification of a Woman (Identificazione di una donna) (1982) 2.121320
Sunset Park (1996) 2.121320
Eaten Alive (1976) 2.121320
Name: rating, dtype: float64