1.确定分析的方向,了解同样的商品是不是自营店普遍比较贵
2.从京东上输入搜索关键字,定向爬取关键字商品的信息
3.数据分析验证第一点

操作:
1.数据预处理
导入所需要的库

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from warnings import filterwarnings
sns.set(palette="summer",font='Microsoft YaHei',font_scale=1.2)
filterwarnings('ignore')

导入数据
df =pd.read_csv(’/home/kesci/input/1357260/csvjd.csv’,encoding=‘gbk’)
数据形状
print(‘数据形状:{}’.format(df.shape))
查找数据重复值、空值
print(‘重复值:{}条’.format(df.duplicated().sum()))
df.isnull().sum()
删除重复值
df.drop_duplicates(inplace=True)
查看信息
df.info()
df.head()

处理comment列数据

def comment_p(x):
x = x.replace(r’+’,’’)
if ‘万’ in x:
x = x.replace(r’万’,’’)
x=float(x)*10000
return x
else:
return x

对comment_p数据类型处理,设置为int
df[‘new_comment’] = df[‘comment’].apply(lambda x:comment_p(x)).astype(‘int’)
创建新的一列数据,将商店类型存储
def new_group(frame):
new_group=[]
for i in range(len(frame)):
if frame.iloc[i,4].find(‘自营’)>=0:
new_group.append(‘京东自营’)
elif frame.iloc[i,4].find(‘旗舰店’)>=0:
new_group.append(‘旗舰店’)
elif frame.iloc[i,4].find(‘专营店’)>=0:
new_group.append(‘专营店’)
else:
new_group.append(‘其它’)
frame[‘newgroup’]=new_group
new_group(df)
查看内容
df.describe()

2.统计不同类型店铺数量

统计这100页中共有多少家店铺

print(‘该100页商品信息中共有:{} 家店铺’.format(df[‘shopname’].nunique()))
画图
s_group = df.groupby(‘newgroup’).shopname.nunique().reset_index(name=‘counts’)
s_group.sort_values(by=‘counts’,ascending=False,inplace=True)

plt.figure(figsize=(12,8))
sns.barplot(x=‘counts’,y=‘newgroup’,data=s_group)
con = list(s_group[‘counts’])
con=sorted(con,reverse=True)
for x,y in enumerate(con):
plt.text(y+0.1,x,’%s’ %y,size=14)
plt.xlabel(’’)
plt.ylabel(’’)
plt.xticks([])
plt.grid(False)
plt.box(False)
plt.title(‘店铺数量’,loc=‘left’,fontsize=20)
plt.show()
3.绘制店铺类型百分比
plt.figure(figsize=(12,8))
size = s_group[‘counts’]
labels = s_group[‘newgroup’]
plt.pie(size,labels=labels,wedgeprops={‘width’:0.35,‘edgecolor’:‘w’},
autopct=’%.2f%%’,pctdistance=0.85,startangle = 90)
plt.axis(‘equal’)
plt.title(‘店铺总数百分比’,loc=‘left’,fontsize=20)
plt.show()
4.统计不同类型店铺的商品数量
plt.figure(figsize=(12,8))
sns.countplot(y=df[‘newgroup’],order = df[‘newgroup’].value_counts().index,data=df)

con = list(df[‘newgroup’].value_counts().values)
con=sorted(con,reverse=True)
for x,y in enumerate(con):
plt.text(y+0.1,x,’%s’ %y,size=14)
plt.xlabel(’’)
plt.ylabel(’’)
plt.xticks([])
plt.grid(False)
plt.box(False)
plt.title(‘商品数量’,loc=‘left’,fontsize=20)
plt.show()
商品总数百分比
plt.figure(figsize=(12,8))
size = df[‘newgroup’].value_counts().values
labels = df[‘newgroup’].value_counts().index
plt.pie(size,labels=labels,wedgeprops={‘width’:0.35,‘edgecolor’:‘w’},
autopct=’%.2f%%’,pctdistance=0.85,startangle = 90)
plt.axis(‘equal’)
plt.title(‘商品总数百分比’,loc=‘left’,fontsize=20)
plt.show()
5. 查看整体价格分布

整体价格分布

直方图
plt.figure(figsize=(12,8))
sns.distplot(df[‘price’])
plt.title(‘价格分布’,loc=‘left’,fontsize=20)
plt.box(False)
plt.show()
6.查看该商品主要集中在哪个价格段
创建一列新数据,将价格分段
result = df
result[‘price_cut’] = pd.cut(x=result[‘price’],bins=[0,100,200,300,400,500,600,800,1000,30000],
labels=[‘100以下’,‘100-200’,‘200-300’,‘300-400’,‘400-500’,‘500-600’,‘600-800’,‘800-1k’,‘1K以上’])
进一步分段
result2 = df[df[‘price’]>=1000]
result2[‘price_cut’] = pd.cut(x=result[‘price’],bins=[1000,2000,5000,10000,30000],
labels=[‘1K-2K’,‘2K-5K’,‘5K-1W’,‘1W以上’])
result3 = pd.DataFrame((result2[‘price_cut’].value_counts()/result.shape[0]).round(3))
使用饼图
from matplotlib.patches import ConnectionPatch
import numpy as np

make figure and assign axis objects

fig = plt.figure(figsize=(12, 8))
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
fig.subplots_adjust(wspace=0)

pie chart parameters

ratios = result.groupby(‘price_cut’).name.count().values
labels = result.groupby(‘price_cut’).name.count().index
explode = [0, 0,0,0,0,0,0,0,0.1]

rotate so that first wedge is split by the x-axis

angle = -180 * ratios[8]
ax1.pie(ratios, autopct=’%1.1f%%’, startangle=angle,
labels=labels, explode=explode,pctdistance=0.85)
ax1.set_title(‘不同价格段的商品占比’)

bar chart parameters

xpos = 0
bottom = 0
ratios = result3.values
width = .2

for j in range(len(ratios)):
height = ratios[j]
ax2.bar(xpos, height, width, bottom=bottom)
ypos = bottom + ax2.patches[j].get_height() / 10
bottom += height
ax2.text(xpos, ypos, ‘%1.1f%%’ % (ax2.patches[j].get_height() * 100),
ha=‘right’)

ax2.set_title(‘1K以上的产品’)
ax2.legend((result3.index))
ax2.axis(‘off’)
ax2.set_xlim(- 2.5 * width, 2.5 * width)

use ConnectionPatch to draw lines between the two plots

get the wedge data

theta1, theta2 = ax1.patches[8].theta1, ax1.patches[8].theta2
center, r = ax1.patches[8].center, ax1.patches[8].r
bar_height = sum([item.get_height() for item in ax2.patches])

draw top connecting line

x = r * np.cos(np.pi / 180 * theta2) + center[0]
y = r * np.sin(np.pi / 180 * theta2) + center[1]
con = ConnectionPatch(xyA=(-width / 2, bar_height), coordsA=ax2.transData,
xyB=(x, y), coordsB=ax1.transData)
con.set_color([0.5, 0.5, 0.5])
con.set_linewidth(2)
ax2.add_artist(con)

draw bottom connecting line

x = r * np.cos(np.pi / 180 * theta1) + center[0]
y = r * np.sin(np.pi / 180 * theta1) + center[1]
con = ConnectionPatch(xyA=(-width / 9, 0), coordsA=ax2.transData,
xyB=(x, y), coordsB=ax1.transData)
con.set_color([0.5, 0.5, 0.5])
ax2.add_artist(con)
con.set_linewidth(2)

plt.show()
线段分段
result4 = result.groupby([‘newgroup’,‘price_cut’]).name.count().reset_index(name=‘counts’)
result4 = pd.DataFrame(result4)
result4.columns = [‘newgroup’,‘price_cut’,‘counts’]

percent=pd.pivot_table(result4,index=[‘newgroup’],columns=[‘price_cut’])
percent.columns = [‘100以下’,‘100-200’,‘200-300’,‘300-400’,‘400-500’,‘500-600’,‘600-800’,‘800-1k’,‘1K以上’]

percent=percent.reset_index()

p_percent=percent.div(percent.sum(axis=1), axis=0)*100
p_percent=p_percent.reset_index()

p_percent.plot(x = ‘newgroup’, kind=‘barh’,stacked = True,mark_right = True,figsize=(16,8))
df_rel=p_percent[p_percent.columns[1:]]

for n in df_rel:
for i, (cs, ab, pc) in enumerate(zip(p_percent.iloc[:, 1:].cumsum(1)[n], p_percent[n], df_rel[n])):
plt.text(cs - ab/2, i, str(np.round(pc, 1)) + ‘%’, va=‘center’, ha=‘center’,size=12)

plt.title(‘不同类型不同价格区间的商品占各类型总数的份额’,loc=‘left’,fontsize=20)
plt.legend(bbox_to_anchor=(1, -0.01),ncol=10,facecolor=‘None’)
plt.xlabel(’’)
plt.ylabel(’’)
plt.xticks([])
plt.grid(False)
plt.box(False)
plt.show()
7.累积成交量
计成交量是:因为京东上的商品只要交易成功不管是否评价,系统都会记录评价人数,因此忽略时效的问题,可当作累计成交来看,只看大概的别纠结哈

使用饼图查看分析
result7 = result.groupby(‘price_cut’).new_comment.sum().reset_index(name=‘total_comment’)
plt.figure(figsize=(12,8))
size = result7[‘total_comment’]
labels = result7[‘price_cut’]
plt.pie(size,labels=labels,
autopct=’%.2f%%’,pctdistance=0.8,explode=[0,0,0,0,0.5,0.5,0.5,0.5,0.5])
plt.title(‘不同价格区间累计成交量’,loc=‘left’,fontsize=16)
plt.axis(‘equal’)
plt.show()
8.不同类型店铺累积成叫量排名
plt.figure(figsize=(12,8))
sns.barplot(x=(result.groupby(‘newgroup’).new_comment.sum().sort_values(ascending=False).values/10000).round(2),
y=result.groupby(‘newgroup’).new_comment.sum().sort_values(ascending=False).index,
data=result,palette=‘summer’)
con = list((result.groupby(‘newgroup’).new_comment.sum().sort_values(ascending=False).values/10000).round(2))

con=sorted(con,reverse=True)

for x,y in enumerate(con):
plt.text(y+0.1,x,’%s (万人)’ %y,size=12)
plt.grid(False)
plt.box(False)
plt.xticks([])
plt.ylabel(’’)
plt.title(‘不同类型的店铺累计成交量排名’,loc=‘left’,fontsize=20)
plt.show()

店铺累积成交量占比
plt.figure(figsize=(12,8))
size = result.groupby(‘newgroup’).new_comment.sum()
labels = size.index
plt.pie(size.values,labels=labels,autopct=’%.2f%%’,pctdistance=0.8,explode=[0.1,0.1,0.1,0.1])
plt.axis(‘equal’)
plt.title(‘累计成交量百分比’,loc=‘left’,fontsize=20)
plt.show()

8.对店铺进行分组,查看每个店铺各个价格段的累计成交量
result5 = result.groupby([‘newgroup’,‘price_cut’]).new_comment.sum().reset_index(name=‘total_comment’)
plt.figure(figsize=(20,4))
n = 0
for x in [‘京东自营’,‘旗舰店’,‘专营店’,‘其它’]:
df = result5[result5[‘newgroup’]==x]
n+=1
plt.subplot(1,4,n)
sns.barplot(x=‘price_cut’,y=df[‘total_comment’]/10000,data=df,palette=‘summer’)
plt.title(x)
plt.xlabel(’’)
plt.ylabel(‘累计成交 ( 万单 )’)
plt.xticks(rotation=45)
plt.grid(False)
plt.box(False)
plt.show()

小节
自营类店铺以不到 10%的商品数量赢得了超过 80% 的成交量
超过 90%的非自营类店铺需要竞争被剩下的不到 20%的资源,
更可怕的是超 30 % 的专营店类店铺只能瓜分剩下不到 3% 的成交量

京东商品比价分析-数据分析项目相关推荐

  1. python共享单车案例分析_python分析数据分析项目:共享单车租用情况影响因素探索分析...

    python分析数据分析项目:共享单车租用情况影响因素探索分析

  2. python手机销售系统_京东手机销售数据分析kaggle复盘python+tableau分析

    1.数据获取 由于手机的价格以及评论数是需要经过javascript渲染的动态信息,单纯用requests模块是爬取不到的.解决方案是首先使用selenium的webbrowser模块使用本地Chro ...

  3. python数据挖掘电影评分分析_Pyhon数据分析项目——男女电影评分差异比较

    <用 Python 玩转数据>数据分析项目 一.程序功能 基于 MovieLens 100k 数据集中男性女性对电影的评分来判断男性还是女性电影 评分的差异性更大. 二.数据来源 数据集下 ...

  4. 7.Python数据分析项目之银行客户流失分析

    1.总结 预测类数据分析项目 流程 具体操作 基本查看 查看缺失值(可以用直接查看方式isnull.图像查看方式查看缺失值missingno).查看数值类型特征与非数值类型特征.一次性绘制所有特征的分 ...

  5. 数据分析项目精讲!电商平台人、货、场分析实战,附数据源

    最近刚给帆软的可视化冬季挑战赛当完评委,发现了一批非常好的数据分析项目案例,经过官方授权后,分享给大家. 今天为大家分享的项目作品是来自于参赛用户枫城的作品,主题是基于人.货.场的电商平台数据分析,分 ...

  6. 【Python有趣打卡】利用pandas完成数据分析项目(二)——爬微信好友+分析

    今天依然是跟着罗罗攀学习数据分析,原创:罗罗攀(公众号:luoluopan1) Python有趣|数据可视化那些事(二) 今天主要是学习pyecharts(http://pyecharts.org/# ...

  7. spark企业级电商分析平台项目实践(一)项目介绍和需求分析

    前言 这个专栏的系列文章,是一个电商分析平台项目实践过程中的记录和总结. 基于 spark2.4.x 和 scala2.11.x 一. 项目概述 访问电商网站时,我们的一些访问行为会产生相应的埋点日志 ...

  8. 数据分析真题日刷 | 京东2019校招数据分析工程师笔试题

    今日真题 网易2018校园招聘数据分析工程师笔试卷(来源:牛客网) 题型 客观题:单选51道,不定项选择12道 完成时间 120分钟 牛客网评估难度系数 3颗星 ❤️ 「更多数据分析真题」 <数 ...

  9. 京东订单交易数据分析

    目录 数据说明 数据说明 数据预处理​​​​​​​ 数据分析 区域分析 价值分析 产品分析 各字段的交互分析 结论说明 数据说明 本次数据来源于京东2020年5月25日 大家电-冰箱的订单数据 按照1 ...

最新文章

  1. 关于网易云音乐爬虫的api接口?
  2. ip协议分析实验报告_入门工业通讯之EtherNet/IP协议分析
  3. Ransomware Locky Analysis
  4. 使用Gradle构建和应用AST转换
  5. python 打卡程序_如何用python实现腾讯文档自动打卡并定时执行
  6. 在linux下一般用scp这个命令来通过ssh传输文件
  7. Vim编辑器显示行号且定义tab键为4个空格
  8. Linux基础----gcc工具的使用
  9. 手机微商城可以安装到虚拟服务器,安装使用:百家CMS微商城系统安装教程(图文说明)...
  10. 虚拟机xp系统联网问题
  11. 0x800704cf 共享打印机_0x800704cF,详细教您Win7访问共享时提示错误0x800704cf怎么办
  12. 首发的400G园区核心交换机,开启园区超宽时代
  13. uniapp swiper waterfall同用 tabbar页面卡顿
  14. cpu排行计算机专业,cpu性能天梯图,教您电脑cpu排行榜
  15. 【预训练语言模型】WKLM: Pretrained Encyclopedia: Weakly Supervised Knowledge-Pretrained Language Model
  16. 关于“运放“这些知识点
  17. Mybatis从入门到精通(全)
  18. 智能指纹门锁芯片方案技术开发
  19. 盘点闪电网络将在2020年爆发的九大理由
  20. matlab怎么添加注释快捷键,Matlab注释技巧

热门文章

  1. 从事计算机编程工作有前途吗,沙坪坝计算机编程培训有前途吗
  2. 形象标识 新松机器人_沈阳新松机器人面试体验贴!
  3. axure实现搜索功能_用Axure实验搜索原型
  4. TI CC32XX SDA中SimpleLink Academy教程翻译(RTOS部分的基础介绍非常易懂)
  5. 宝塔自定义html,宝塔面板Nginx编译安装添加自定义模块PageSpeed
  6. 视网膜数据集(3)STARE
  7. a50交割日时间表2021(a50三大主要功能)
  8. java 时间纪元与时区介绍
  9. 诺基亚N900安装Android 2.2改版系统Nitdroid教程
  10. [BZOJ 1296][SCOI2009]粉刷匠