在jupyter实现数据的可视化 |
您所在的位置:网站首页 › jupyter读取数据集 › 在jupyter实现数据的可视化 |
程序员健身是为了保养还是保命?参与话题讨论赢好礼 >>>
import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt %matplotlib inline df=pd.read_csv('D:\order.csv',encoding="gbk") #读取数据 df.head(100) maoyan_key_factors = df[['title','score']] maoyan_key_factors.head(100) maoyan_score = maoyan_key_factors[['title', 'score']] groupby_score = maoyan_score.groupby('score') total_groupby_score = groupby_score.count() print(total_groupby_score.rename(columns={'score':'Total'})) c_score = total_groupby_score.plot(kind='bar') c_score.set_title('Scoring statistics for the top 100 movie of cat eye movie') c_score.set_ylabel('Count')
------------------------------------------------------ 我自己的代码如下: import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt %matplotlib inline
df=pd.read_csv('D:\order.csv',encoding="gbk") #读取数据 df.head(1000) print(df)这块可以直接把 df打印出来看下结果 maoyan_key_factors = df[['x_id','pay_amount']] maoyan_key_factors.head(100) maoyan_score = maoyan_key_factors[['x_id', 'pay_amount']] groupby_score = maoyan_score.groupby('x_id') total_groupby_score = groupby_score.count() total_groupby_score.rename(columns={'pay_amount':'Total'}) c_score = total_groupby_score.plot(kind='bar') c_score.set_title('Scoring statistics for the top 100 movie of cat eye movie') c_score.set_ylabel('Count') 图表自己都出来了,非常方便。 感叹,这要拿编程语言写半天,还不知道对错!!!!! 备注:csv的文件格式如下:逗号分隔 order_id 订单号 x_id 商 户id total_amount 订单金额 pay_amount 支付金额 order_id,x_id,total_amount,pay_amount 201906201520073329387129,33,100,1 201906201527017853969512,33,100,1 201906201533561091291430,33,100,1 201906201544143447127726,11,10,1 201906201545406603430237,33,30,30 201906201548385687686104,11,10,1 201906201556535835619315,11,10,1 201906201601409742676819,11,10,1 201906201604045190468329,11,10,1 201906201612152955596419,11,18,1
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |