大數(shù)據(jù)畢業(yè)設(shè)計(jì) 小紅書(shū)數(shù)據(jù)分析與可視化
0 前言
??這兩年開(kāi)始畢業(yè)設(shè)計(jì)和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長(zhǎng)自己做的項(xiàng)目系統(tǒng)達(dá)不到老師的要求。
?? 大數(shù)據(jù)畢業(yè)設(shè)計(jì) 小紅書(shū)數(shù)據(jù)分析與可視化
??學(xué)長(zhǎng)這里給一個(gè)題目綜合評(píng)分(每項(xiàng)滿分5分)
難度系數(shù):3分
工作量:3分
創(chuàng)新點(diǎn):4分
畢設(shè)幫助,選題指導(dǎo),技術(shù)解答,歡迎打擾,見(jiàn)B站個(gè)人主頁(yè)
https://space.bilibili.com/33886978
1 課題背景
小紅書(shū)是一個(gè)生活方式平臺(tái)和消費(fèi)決策入口,截至2019年7月,小紅書(shū)用戶數(shù)已超過(guò)3億;截至到2019年10月,小紅書(shū)月活躍用戶數(shù)已經(jīng)過(guò)億,其中70%新增用戶是90后。 ? 在小紅書(shū)社區(qū),用戶通過(guò)文字、圖片、視頻筆記的分享,記錄了這個(gè)時(shí)代年輕人的正能量和美好生活,小紅書(shū)通過(guò)機(jī)器學(xué)習(xí)對(duì)海量信息和人進(jìn)行精準(zhǔn)、高效匹配。小紅書(shū)旗下設(shè)有電商業(yè)務(wù)。
分析角度: ? 服飾行業(yè)趨勢(shì) ? 小紅書(shū)粉絲用戶畫(huà)像 ? 小紅書(shū)筆記??熱門分析 ? 小紅書(shū)服裝行業(yè)營(yíng)銷策略
2 數(shù)據(jù)庫(kù)依賴
導(dǎo)入依賴包
? ?import numpy as np
? ?import pandas as pd
? ?from pyecharts import options as opts
? ?from pyecharts.charts import *
? ?from pyecharts.components import Table
3 分析服飾行業(yè)筆記數(shù)據(jù)趨勢(shì)數(shù)據(jù)
3.1數(shù)據(jù)一覽
# 讀取服飾行業(yè)筆記數(shù)據(jù)趨勢(shì)數(shù)據(jù)
? ?data_trend = pd.read_excel(r'/服飾行業(yè)筆記數(shù)據(jù)趨勢(shì).xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_trend.head(5)
?
? ?# 查看數(shù)據(jù)信息
? ?data_trend.info()
?
? ?# 轉(zhuǎn)化日期列數(shù)據(jù)類型
? ?data_trend['日期'] = data_trend['日期'].astype('str')
? ?# 將當(dāng)日總數(shù)據(jù)處理為每篇筆記的平均數(shù)據(jù)
? ?for i in ['當(dāng)日點(diǎn)贊數(shù)','當(dāng)日收藏?cái)?shù)','當(dāng)日評(píng)論數(shù)','當(dāng)日分享數(shù)','當(dāng)日閱讀數(shù)']:
? ? ? ?data_trend[i.replace('當(dāng)日', '平均')] = round(data_trend[i]/data_trend['當(dāng)日筆記篇數(shù)'],2)
? ? ? ?data_trend.drop(i, axis=1, inplace=True)
? ?# 查看處理后的服飾行業(yè)筆記數(shù)據(jù)趨勢(shì)數(shù)據(jù)
? ?data_trend.head(5)
?
? ?# 聚合各行業(yè)近三十日的每日數(shù)據(jù)
? ?data_trend_by_industry = data_trend.groupby(['行業(yè)名稱']).agg(
? ? ? ?{'當(dāng)日筆記篇數(shù)': lambda x:round(np.mean(x),2),
? ? ? ?'平均點(diǎn)贊數(shù)': lambda x:round(np.mean(x),2),
? ? ? ? '平均收藏?cái)?shù)': lambda x:round(np.mean(x),2),
? ? ? ? '平均評(píng)論數(shù)': lambda x:round(np.mean(x),2),
? ? ? ? '平均分享數(shù)': lambda x:round(np.mean(x),2),
? ? ? ? '平均閱讀數(shù)': lambda x:round(np.mean(x),2),
? ? ? ? '平均互動(dòng)量': lambda x:round(np.mean(x),2),
? ? ? ?}).reset_index()
? ?data_trend_by_industry.head(5)

3.2 可視化分析
# 近三十天小紅書(shū)服飾行業(yè)數(shù)據(jù)-相關(guān)系數(shù)熱力圖
? ?data_trend_corr=data_trend.corr()
? ?rows = data_trend_corr.index.size
? ?cols = data_trend_corr.columns.size
? ?# 熱力圖所需數(shù)據(jù)
? ?data_trend_corr_heatmap = [[i, j, round(float(data_trend_corr.iloc[i, j]), 3)] for i in range(rows) for j in range(cols)]
? ?
? ?heatmap_trend_corr = HeatMap(
? ? ? ?init_opts=opts.InitOpts(
? ? ? ? ? ?width='950px',
? ? ? ? ? ?)
? ?)
? ?heatmap_trend_corr.add_xaxis(
? ? ? ?data_trend_corr.index.tolist(),
? ? ? ?)
? ?heatmap_trend_corr.add_yaxis(
? ? ? ? ? ?'相關(guān)系數(shù)',
? ? ? ? ? ?data_trend_corr.columns.tolist(),
? ? ? ? ? ?data_trend_corr_heatmap,
? ? ? ? ? ?label_opts=opts.LabelOpts(
? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ?position='inside'),
? ? ? ?)
? ?heatmap_trend_corr.set_global_opts(
? ? ? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ? ? ?title='相關(guān)系數(shù)熱力圖',
? ? ? ? ? ? ? ?subtitle='近三十日小紅書(shū)服飾行業(yè)數(shù)據(jù)',
? ? ? ? ? ? ? ?pos_left='center'),
? ? ? ? ? ?legend_opts=opts.LegendOpts(
? ? ? ? ? ? ? ?is_show=False,
? ? ? ? ? ?),
? ? ? ? ? ?xaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?type_='category',
? ? ? ? ? ? ? ?splitarea_opts=opts.SplitAreaOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?areastyle_opts=opts.AreaStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?opacity=1
? ? ? ? ? ? ? ? ? ?)
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?axislabel_opts=opts.LabelOpts(
? ? ? ? ? ? ? ? ? ?font_size=14,
? ? ? ? ? ? ? ? ? ?rotate=-25,
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?interval=0
? ? ? ? ? ?),
? ? ? ? ? ?yaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?name='',
? ? ? ? ? ? ? ?type_='category',
? ? ? ? ? ? ? ?splitarea_opts=opts.SplitAreaOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?areastyle_opts=opts.AreaStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?opacity=1
? ? ? ? ? ? ? ? ? ?)
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? axislabel_opts=opts.LabelOpts(
? ? ? ? ? ? ? ? ? ?font_size=14
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?interval=0
? ? ? ? ? ?),
? ? ? ? ? ?visualmap_opts=opts.VisualMapOpts(
? ? ? ? ? ? ? ?min_=-1,
? ? ? ? ? ? ? ?max_=1,
? ? ? ? ? ? ? ?is_show=False,
? ? ? ? ? ?)
? ? ? ?)
? ?heatmap_trend_corr.render_notebook()

由可視化結(jié)果可見(jiàn)服飾行業(yè)筆記數(shù)據(jù)各因素間的相關(guān)程度;
當(dāng)日筆記篇數(shù)與其他因素都是沒(méi)有什么相關(guān)性,因?yàn)槠渌蛩囟际歉鶕?jù)單篇筆記得到的互動(dòng)數(shù)據(jù),與總的筆記篇數(shù)無(wú)關(guān);
平均互動(dòng)量與平均點(diǎn)贊數(shù)和平均收藏?cái)?shù)相關(guān)性最大,互動(dòng)量這個(gè)值大概率是根據(jù)點(diǎn)贊數(shù)和/或收藏?cái)?shù)計(jì)算得到的;
其他因素之間多為(弱)正相關(guān)。
3.3 可視化分析
def bar_chart(desc, title_pos):
? ? ? ?data_trend_by_industry_top10 = data_trend_by_industry.sort_values(desc, ascending=False).head(10).round(2)
? ? ? ?print(desc + 'top10: ' + str(data_trend_by_industry_top10['行業(yè)名稱'].tolist()))
? ? ? ?chart = Bar()
? ? ? ?chart.add_xaxis(
? ? ? ? ? ?data_trend_by_industry_top10['行業(yè)名稱'].tolist()
? ? ? ?)
? ? ? ?chart.add_yaxis(
? ? ? ? ? ?'',
? ? ? ? ? ?data_trend_by_industry_top10[desc].tolist()
? ? ? ?)
? ?
? ? ? ?chart.set_global_opts(
? ? ? ? ? ?xaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?is_scale=True,
? ? ? ? ? ? ? ?axislabel_opts={'rotate': '-25'},
? ? ? ? ? ? ? ?splitline_opts=opts.SplitLineOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?linestyle_opts=opts.LineStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?type_='dashed'))
? ? ? ? ? ?),
? ? ? ? ? ?yaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?is_scale=True,
? ? ? ? ? ? ? ?name='',
? ? ? ? ? ? ? ?type_='value',
? ? ? ? ? ? ? ?splitline_opts=opts.SplitLineOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?linestyle_opts=opts.LineStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?type_='dashed'))
? ? ? ? ? ?),
? ? ? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ? ? ?title='服飾行業(yè)-' + desc + '-Top10',
? ? ? ? ? ? ? ?subtitle=f'日期范圍:20220421~20220520 ??',
? ? ? ? ? ? ? ?pos_left=title_pos[0],
? ? ? ? ? ? ? ?pos_top=title_pos[1],
? ? ? ? ? ? ? ?title_textstyle_opts=opts.TextStyleOpts(
? ? ? ? ? ? ? ? ? ?color='#ea517f',
? ? ? ? ? ? ? ? ? ?font_family='cursive',
? ? ? ? ? ? ? ? ? ?font_size=19)
? ? ? ? ? ?),
? ? ? ?)
? ? ? ?return chart
? ?# 新建組合圖表Grid
? ?grid = Grid(
? ? ? ?init_opts=opts.InitOpts(
? ? ? ? ? ?theme='light',
? ? ? ? ? ?width='1300px',
? ? ? ? ? ?height='1200px')
? ?)
? ?grid.add(
? ? ? ?bar_chart('當(dāng)日筆記篇數(shù)', ['5%', '3%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='10%', ? # 指定Grid中子圖的位置
? ? ? ? ? ?pos_bottom='70%',
? ? ? ? ? ?pos_left='10%',
? ? ? ? ? ?pos_right='60%'
? ? ? ?)
? ?)
? ?grid.add(
? ? ? ?bar_chart('平均點(diǎn)贊數(shù)', ['55%', '3%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='10%',
? ? ? ? ? ?pos_bottom='70%',
? ? ? ? ? ?pos_left='60%',
? ? ? ? ? ?pos_right='10%'
? ? ? ?)
? ?)
? ?grid.add(
? ? ? ?bar_chart('平均收藏?cái)?shù)', ['5%', '35%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='40%',
? ? ? ? ? ?pos_bottom='40%',
? ? ? ? ? ?pos_left='10%',
? ? ? ? ? ?pos_right='60%'
? ? ? ?)
? ?)
? ?grid.add(
? ? ? ?bar_chart('平均評(píng)論數(shù)', ['55%', '35%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='40%',
? ? ? ? ? ?pos_bottom='40%',
? ? ? ? ? ?pos_left='60%',
? ? ? ? ? ?pos_right='10%'
? ? ? ?)
? ?)
? ?grid.add(
? ? ? ?bar_chart('平均分享數(shù)', ['5%', '65%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='70%',
? ? ? ? ? ?pos_bottom='10%',
? ? ? ? ? ?pos_left='10%',
? ? ? ? ? ?pos_right='60%'
? ? ? ?)
? ?)
? ?grid.add(
? ? ? ?bar_chart('平均閱讀數(shù)', ['55%', '65%']),
? ? ? ?is_control_axis_index=False,
? ? ? ?grid_opts=opts.GridOpts(
? ? ? ? ? ?pos_top='70%',
? ? ? ? ? ?pos_bottom='10%',
? ? ? ? ? ?pos_left='60%',
? ? ? ? ? ?pos_right='10%'
? ? ? ?)
? ?)
? ?grid.render_notebook()

?

由可視化結(jié)果可知,“馬甲”行業(yè)的筆記質(zhì)量最高,雖然“馬甲”行業(yè)的總筆記數(shù)前十都排不到,但筆記篇均數(shù)據(jù)卻都一馬當(dāng)先。
4. 分析服飾行業(yè)內(nèi)容關(guān)鍵詞數(shù)據(jù)
4.1 數(shù)據(jù)一覽
? data_keyword = pd.read_excel(r'服飾行業(yè)內(nèi)容關(guān)鍵詞TOP100.xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_keyword.head(5)
? ?# 查看數(shù)據(jù)信息
? ?data_keyword.info()

? ?# 按內(nèi)容關(guān)鍵詞聚合數(shù)據(jù)
? ?data_keyword_all = data_keyword.groupby(['內(nèi)容關(guān)鍵詞']).agg(
? ? ? ?{
? ? ? ? ? ?'平均點(diǎn)贊數(shù)': 'mean',
? ? ? ? ? ?'平均收藏?cái)?shù)': 'mean',
? ? ? ? ? ?'平均評(píng)論數(shù)': 'mean',
? ? ? ? ? ?'平均分享數(shù)': 'mean',
? ? ? ? ? ?'平均閱讀數(shù)': 'mean',
? ? ? ? ? ?'活躍數(shù)': 'mean',
? ? ? ?}).reset_index()
4.2 可視化分析
?tab = Tab()
? ?# 關(guān)鍵詞列表
? ?type_list = list(data_keyword_all)[1:]
? ?for i in type_list:
? ? ? ?keyword_data = data_keyword_all[['內(nèi)容關(guān)鍵詞', i]].apply(lambda x: tuple(x), axis=1).values.tolist()
? ? ? ?word_cloud_keyword = (
? ? ? ? ? ?WordCloud(init_opts=opts.InitOpts(width='1200px', height='600px', theme='light'))
? ? ? ? ? ? ? ?.add(series_name='評(píng)論熱詞',
? ? ? ? ? ? ? ? ? ? data_pair=keyword_data,
? ? ? ? ? ? ? ? ? ? word_size_range=[30, 150],
? ? ? ? ? ? ? ? ? ? rotate_step=45,
? ? ? ? ? ? ? ? ? ? textstyle_opts=opts.TextStyleOpts(font_family='cursive'),
? ? ? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ?.set_global_opts(
? ? ? ? ? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ? ? ? ? ?title='以文章'+i.replace('平均','')+'為指標(biāo)得到的內(nèi)容關(guān)鍵詞熱詞',
? ? ? ? ? ? ? ? ? ?title_textstyle_opts=opts.TextStyleOpts(font_size=20, font_family='cursive'),
? ? ? ? ? ? ? ? ? ?pos_left='center',
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?tooltip_opts=opts.TooltipOpts(is_show=True),
? ? ? ? ? ?)
? ? ? ?)
? ? ? ?tab.add(word_cloud_keyword, i.replace('平均',''))
? ?tab.render_notebook()

由可視化結(jié)果可見(jiàn)不同指標(biāo)下的內(nèi)容關(guān)鍵詞熱詞;
以點(diǎn)贊、收藏和分享數(shù)為指標(biāo)的情況下,“吊帶合集”為最熱內(nèi)容關(guān)鍵詞;
以評(píng)論數(shù)為指標(biāo)的情況下,“格裙送出計(jì)劃”為最熱內(nèi)容關(guān)鍵詞;
以閱讀數(shù)為指標(biāo)的情況下,“明星撞衫”為最熱內(nèi)容關(guān)鍵詞。
5. 分析服飾行業(yè)品類數(shù)據(jù)
5.1 數(shù)據(jù)一覽
# 讀取數(shù)據(jù)(服飾行業(yè)品類分析-大類占比.xlsx 和 服飾行業(yè)品類分析-細(xì)分品類占比.xlsx是同一數(shù)據(jù))
? ?data_category = pd.read_excel(r'服飾行業(yè)品類分析-大類占比.xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_category.head(5)
? ?# 查看數(shù)據(jù)信息
? ?data_category.info()
5.2 可視化分析
data_category = data_category.sort_values(by='筆記篇數(shù)', ascending=False)
? ?data_category_bar = (
? ? ? ?Bar()
? ? ? ?.add_xaxis(data_category['大類'].tolist())
? ? ? ?.add_yaxis('筆記篇數(shù)', data_category['筆記篇數(shù)'].tolist())
? ? ? ?.set_global_opts(
? ? ? ? ? ?title_opts=opts.TitleOpts(title='小紅書(shū)服飾行業(yè)品類筆記數(shù)'),
? ? ? ? ? ?datazoom_opts=opts.DataZoomOpts(is_show=True,range_start=0,range_end=30),
? ? ? ? ? ?xaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?is_scale=True,
? ? ? ? ? ? ? ?splitline_opts=opts.SplitLineOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?linestyle_opts=opts.LineStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?type_='dashed'),
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?axislabel_opts=opts.LabelOpts(
? ? ? ? ? ? ? ? ? ?rotate=-25,
? ? ? ? ? ? ? ? ? ?interval=0,
? ? ? ? ? ? ? ?),
? ? ? ? ? ?),
? ? ? ? ? ?yaxis_opts=opts.AxisOpts(
? ? ? ? ? ? ? ?is_scale=True,
? ? ? ? ? ? ? ?# 網(wǎng)格線配置
? ? ? ? ? ? ? ?splitline_opts=opts.SplitLineOpts(
? ? ? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ? ? ? ? ?linestyle_opts=opts.LineStyleOpts(
? ? ? ? ? ? ? ? ? ? ? ?type_='dashed'))
? ? ? ? ? ?),
? ? ? ?)
? ?)
? ?data_category_bar.render_notebook()

由可視化結(jié)果可知“連衣裙”、“T恤”和“休閑褲”為篇數(shù)最多的行業(yè)文章。
6. 分析服飾行業(yè)年齡分布數(shù)據(jù)
6.1 數(shù)據(jù)一覽
data_age = pd.read_excel(r'服飾行業(yè)年齡分布.xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_age.head(5)
? ?# 查看數(shù)據(jù)信息
? ?data_age.info()
? ?industry_list = data_age['行業(yè)名稱'].unique()
? ?industry_list
6.2 可視化分析
? # 新建柱狀圖
? ?salary_city_bar = Bar(
? ? ? ?init_opts=opts.InitOpts(
? ? ? ? ? ?# 設(shè)置圖寬
? ? ? ? ? ?width='1200xp',
? ? ? ? ? ?# 設(shè)置柱狀圖主題
? ? ? ? ? ?theme='light',
? ? ? ?)
? ?)
? ?# 添加橫軸數(shù)據(jù)
? ?salary_city_bar.add_xaxis(
? ? ? ?list(industry_list),
? ?)
? ?salary_city_bar.add_yaxis(
? ? ? ?'<18',
? ? ? ?list(data_age[data_age['年齡段']=='<18']['占比'].apply(lambda x: round(x*100,2))),
? ? ? ?stack='年齡段',
? ?)
? ?salary_city_bar.add_yaxis(
? ? ? ?'18-24',
? ? ? ?list(data_age[data_age['年齡段']=='18-24']['占比'].apply(lambda x: round(x*100,2))),
? ? ? ?stack='年齡段',
? ?)
? ?salary_city_bar.add_yaxis(
? ? ? ?'25-34',
? ? ? ?list(data_age[data_age['年齡段']=='25-34']['占比'].apply(lambda x: round(x*100,2))),
? ? ? ?stack='年齡段',
? ?)
? ?salary_city_bar.add_yaxis(
? ? ? ?'35-44',
? ? ? ?list(data_age[data_age['年齡段']=='35-44']['占比'].apply(lambda x: round(x*100,2))),
? ? ? ?stack='年齡段',
? ?)
? ?salary_city_bar.add_yaxis(
? ? ? ?'>44',
? ? ? ?list(data_age[data_age['年齡段']=='>44']['占比'].apply(lambda x: round(x*100,2))),
? ? ? ?stack='年齡段',
? ?)
? ?salary_city_bar.set_series_opts(
? ? ? ?label_opts=opts.LabelOpts(
? ? ? ? ? ?# 不顯示數(shù)據(jù)項(xiàng)的標(biāo)簽
? ? ? ? ? ?is_show=False,
? ? ? ?),
? ?)
? ?salary_city_bar.set_global_opts(
? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ?# 設(shè)置標(biāo)題
? ? ? ? ? ?title='小紅書(shū)各服飾行業(yè)用戶年齡分布百分比',
? ? ? ? ? ?# 居中顯示
? ? ? ? ? ?pos_left='center',
? ? ? ?),
? ? ? ?tooltip_opts=opts.TooltipOpts(
? ? ? ? ? ?# 數(shù)據(jù)項(xiàng)圖形觸發(fā)
? ? ? ? ? ?trigger='item',
? ? ? ? ? ?# 十字準(zhǔn)星指示器
? ? ? ? ? ?axis_pointer_type='cross',
? ? ? ?),
? ? ? ?yaxis_opts=opts.AxisOpts(
? ? ? ? ? ?splitline_opts=opts.SplitLineOpts(
? ? ? ? ? ? ? ?# 顯示坐標(biāo)軸橫線
? ? ? ? ? ? ? ?is_show=True,
? ? ? ? ? ?)
? ? ? ?),
? ? ? ?xaxis_opts=opts.AxisOpts(
? ? ? ? ? ?axislabel_opts=opts.LabelOpts(
? ? ? ? ? ? ? ?rotate=-25,
? ? ? ? ? ? ? ?interval=0,
? ? ? ? ? ?),
? ? ? ?),
? ? ? ?legend_opts=opts.LegendOpts(
? ? ? ? ? ?# 把圖例放在標(biāo)題下方
? ? ? ? ? ?pos_top='5%',
? ? ? ?)
? ?)
? ?salary_city_bar.render_notebook()

由可視化結(jié)果可知小紅書(shū)服飾行業(yè)整體以18-34歲用戶群體占比最多,35歲以上用戶占比極少。
7. 分析服飾行業(yè)粉絲地域分布數(shù)據(jù)
7.1 數(shù)據(jù)一覽
? data_region = pd.read_excel(r'服飾行業(yè)粉絲地域分布.xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_region.head(5)
? ?# 查看數(shù)據(jù)信息
? ?data_region.info()
? ?# 計(jì)算小紅書(shū)服裝行業(yè)的用戶地域平均分布
? ?data_region_by_province = data_region.groupby(['省份']).agg({'占比':lambda x:round(np.mean(x),2)}).sort_values(by='占比', ascending=False).reset_index()
? ?data_region_by_province.head(5)
7.2 可視化分析
benefitsPie = Pie(
? ? ? ?init_opts=opts.InitOpts(
? ? ? ? ? ?# 設(shè)置圖例的寬高
? ? ? ? ? ?width='1200px',
? ? ? ?)
? ?)
? ?# 添加數(shù)據(jù)
? ?benefitsPie.add(
? ? ? ?'',
? ? ? ?data_region_by_province.values,
? ? ? ?# 設(shè)計(jì)為環(huán)形
? ? ? ?# radius=["45%", "70%"],
? ? ? ?radius=["35%", "60%"],
? ?)
? ?benefitsPie.set_global_opts(
? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ?# 設(shè)置標(biāo)題
? ? ? ? ? ?title='小紅書(shū)服裝行業(yè)的用戶地域平均分布',
? ? ? ? ? ?# 居中顯示
? ? ? ? ? ?pos_left='center',
? ? ? ?),
? ? ? ?legend_opts=opts.LegendOpts(
? ? ? ? ? ?# 把圖例放在標(biāo)題下方
? ? ? ? ? ?pos_top='5%',
? ? ? ?),
? ?)
? ?benefitsPie.render_notebook()

由可視化結(jié)果可知小紅書(shū)服飾行業(yè)用戶地域分布以廣東、北京、上海占比較多。
7.3 可視化分析
? map_region_industry_by_province =Map()
? ?map_region_industry_by_province.add("用戶占比", data_region_by_province.values, "china",is_map_symbol_show=False)
? ?map_region_industry_by_province.set_global_opts(
? ? ? ? ? ?title_opts=opts.TitleOpts(title="小紅書(shū)服飾行業(yè)各省用戶百分比"),
? ? ? ? ? ?visualmap_opts=opts.VisualMapOpts(max_=16.5, is_piecewise=True)
? ? ? ?)
? ?map_region_industry_by_province.render_notebook()

由可視化結(jié)果可知小紅書(shū)服飾行業(yè)用戶地域分布以東南沿海為主,內(nèi)容省份只有北京、四川用戶較多。
7.4 可視化分析
? data_region_industry_by_province = [[i,round(np.mean(data_region[data_region['省份']==i]['占比']),2),data_region['行業(yè)名稱'][data_region[data_region['省份']==i]['占比'].idxmax()]] for i in data_region['省份'].unique()]
? ?table_region_industry_by_province = Table()
? ?headers = ["省份", "用戶百分比", "該省最多人關(guān)注的行業(yè)"]
? ?table_region_industry_by_province.add(headers, data_region_industry_by_province)
? ?table_region_industry_by_province.set_global_opts(
? ? ? ?title_opts=opts.ComponentTitleOpts(title="小紅書(shū)不同地域用戶的分布及主要關(guān)注行業(yè)")
? ?)
? ?table_region_industry_by_province.render_notebook()
? ?table_region_industry_by_province.render('table_region_industry_by_province.html')
? ?# 不知道為什么不顯示Table,可以下載打開(kāi)HTML文件查看可視化結(jié)果
? ?data_region_industry_by_province
8. 分析服飾行業(yè)評(píng)論熱詞數(shù)據(jù)
8.1 數(shù)據(jù)一覽
data_commend = pd.read_excel(r'服飾行業(yè)評(píng)論熱詞.xlsx')
? ?# 查看數(shù)據(jù),據(jù)了解數(shù)據(jù)內(nèi)容
? ?data_commend.head(5)
? ?# 查看數(shù)據(jù)信息
? ?data_commend.info()
? ?# 行業(yè)數(shù)據(jù)
? ?industry_list = data_commend['行業(yè)名稱'].unique()
? ?industry_list
8.2 可視化分析
? tab_commend = Tab()
? ?for i in industry_list:
? ? ? ?temp_data = data_commend[data_commend['行業(yè)名稱']==i].groupby(['comment_word']).agg({'總計(jì)': sum, }).reset_index()
? ? ? ?keyword_data = temp_data[['comment_word', '總計(jì)']].apply(lambda x: tuple(x), axis=1).values.tolist()
? ? ? ?word_cloud_keyword = (
? ? ? ? ? ?WordCloud(init_opts=opts.InitOpts(width='1200px', height='600px', theme='light'))
? ? ? ? ? ? ? ?.add(series_name='評(píng)論熱詞',
? ? ? ? ? ? ? ? ? ? data_pair=keyword_data,
? ? ? ? ? ? ? ? ? ? word_size_range=[30, 150],
? ? ? ? ? ? ? ? ? ? rotate_step=45,
? ? ? ? ? ? ? ? ? ? textstyle_opts=opts.TextStyleOpts(font_family='cursive'),
? ? ? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ?.set_global_opts(
? ? ? ? ? ? ? ?title_opts=opts.TitleOpts(
? ? ? ? ? ? ? ? ? ?title=i+'行業(yè)評(píng)論熱詞',
? ? ? ? ? ? ? ? ? ?title_textstyle_opts=opts.TextStyleOpts(font_size=25, font_family='cursive'),
? ? ? ? ? ? ? ? ? ?pos_left='center',
? ? ? ? ? ? ? ?),
? ? ? ? ? ? ? ?tooltip_opts=opts.TooltipOpts(is_show=True),
? ? ? ? ? ?)
? ? ? ?)
? ? ? ?tab_commend.add(word_cloud_keyword, i)
? ?tab_commend.render_notebook()

由可視化結(jié)果可見(jiàn)不同行業(yè)下的文章評(píng)論熱詞。
畢設(shè)幫助,選題指導(dǎo),技術(shù)解答,歡迎打擾,見(jiàn)B站個(gè)人主頁(yè)
https://space.bilibili.com/33886978