Python学习第三十五天,简易的数据分析(三)

88 阅读1分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第35天,点击查看活动详情

日期销量

为了直观的了解每日的销量状况,这边使用折线图来展现销量

lis = [i.replace("/","-") for i in shopping_data['update_time']]
date = pd.Series(lis)
shopping_data["update_time"]=date
# 转成datetime格式,方便排序
shopping_data['update_time']=pd.to_datetime(shopping_data['update_time'],format='%Y-%m-%d')
date_rank = shopping_data.groupby("update_time").sum()
print(date_rank.index)
plt.rcParams['font.sans-serif']=['SimHei']
# 必加,否则会无法显示中文
plt.figure(figsize=[10,10])
plt.title("日期销量")
plt.plot(date_rank.index,date_rank["sale_count"])
plt.show()

效果:

image.png

image.png

很明显,双十一的前几天大家的购买欲望都很足,消费一波后大家的钱包空了,购买量也很明显的减少了。

产品评论量前10

c_rank = shopping_data.groupby("title").sum().sort_values(by="comment_count",ascending=False).head(10)
print(c_rank)
plt.rcParams['font.sans-serif']=['SimHei']
# 必加,否则会无法显示中文
plt.figure(figsize=[10,10])
plt.title("评论量前10")
plt.plot(c_rank.index,c_rank["comment_count"])
plt.xticks(rotation=270)
plt.show()

效果:

image.png

image.png 很明显的,这个第一个产品评论量,遥遥领先,实际上这不太能看出什么,但一般来说第一个产品肯定是在市场上流通量相对好的。毕竟黑粉也是粉嘛。

店面评论量前10

c_rank = shopping_data.groupby("店名").sum().sort_values(by="comment_count",ascending=False).head(10)
print(c_rank)
plt.rcParams['font.sans-serif']=['SimHei']
# 必加,否则会无法显示中文
plt.figure(figsize=[10,10])
plt.title("店名评论量前10")
plt.bar(c_rank.index,c_rank["comment_count"])
plt.xticks(rotation=270)
plt.show()

image.png image.png

这边可以看到,悦诗风吟的产品可能说市场流通量更多。 。

总结

简易的数据分析实际上不难,重点在于要动脑,开发出有用的数据以供他人观看。