import pandas as pd编程
import numpy as np编程语言
import matplotlibpandas
import matplotlib.pyplot as pltit
%matplotlib inlineimport
df=pd.read_csv('D:\order.csv',encoding="gbk") #读取数据
df.head(100) coding
maoyan_key_factors = df[['title','score']]
maoyan_key_factors.head(100)
csv
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'}))
numpy
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')
im
------------------------------------------------------支付
我本身的代码以下:
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