首页 > 编程语言 > 详细

Python进行数据分析(二)初步学习2

时间:2017-09-27 23:41:57      阅读:362      评论:0      收藏:0      [点我收藏+]
# -*- 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

 

Python进行数据分析(二)初步学习2

原文:http://www.cnblogs.com/douzujun/p/7604498.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!