码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-09-27 23:55:12      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:tle   mat   imp   head   utf-8   names   author   waiting   ati   

# -*- 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|Childrens|Comedy
1         2                      Jumanji (1995)  Adventure|Childrens|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

标签:tle   mat   imp   head   utf-8   names   author   waiting   ati   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!