1. 導入依賴庫
import pandas
as pd
import matplotlib
as plt
import seaborn
as sns
import os
import requests
from pyecharts
.charts
import *
import pyecharts
.options
as opts
from pyecharts
.globals import ThemeType
from pyecharts
.commons
.utils
import JsCode
2.數據基本處理
df_100
= pd
.read_excel
('B站熱門100期.xlsx')
df_100
.head
(3)
期數標題up主播放量點贊視頻標簽視頻鏈接
0| 第1期 | 這集vlog我們拍了十年,致最美好的青春 | AresserA-Vlog | 438.9萬 | 6.6萬 | 暴風流淚推薦!今天也是為別人的神仙愛情流淚的一天! | https://www.bilibili.com/video/BV14b411J7ML |
1| 第1期 | 華農兄弟:兄弟家的魚跑河里去了,幫他網回來,一網下去還不少 | 華農兄弟 | 240.5萬 | 2.1萬 | 村霸兄弟又上線了!這次他們把魔抓伸向了兄弟家的魚! | https://www.bilibili.com/video/BV15b41147uu |
2| 第1期 | 【性轉版】回家的誘惑(劉亦菲/劉昊然/鄧倫/吳磊/賈玲) | 蘭徹lancche | 405.5萬 | 4.1萬 | NaN | https://www.bilibili.com/video/BV1xb411n7L6 |
df_he
= pd
.read_excel
('何同學.xlsx')
df_he
.head
(3)
標題BV號分享彈幕量投幣播放量收藏時長時間點贊評論鏈接
0| 【何同學】整理自己的生活(P2附庫克采訪) | BV13v411v7Zo | 87493 | 104242 | 1006206 | 6890862 | 307790 | 1663 | 2021-02-17 | 1035322 | 28182 | http://www.bilibili.com/video/BV13v411v7Zo |
1| 【何同學】這視頻能讓你戒手機 | BV1ev411x7en | 165395 | 87771 | 1556559 | 9395725 | 635917 | 738 | 2021-01-06 | 1458370 | 31807 | http://www.bilibili.com/video/BV1ev411x7en |
2| 【何同學】80年代的電腦能做什么?蘋果麥金塔深度體驗 | BV1cy4y1k7A2 | 88683 | 57512 | 1714349 | 7864361 | 463415 | 670 | 2020-11-05 | 1404036 | 20497 | http://www.bilibili.com/video/BV1cy4y1k7A2 |
df_100
.info
()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2499 entries, 0 to 2498
Data columns (total 7 columns):# Column Non-Null Count Dtype
--- ------ -------------- ----- 0 期數 2499 non-null object1 標題 2499 non-null object2 up主 2499 non-null object3 播放量 2499 non-null object4 點贊 2499 non-null object5 視頻標簽 2453 non-null object6 視頻鏈接 2499 non-null object
dtypes: object(7)
memory usage: 136.8+ KB
df_he
.info
()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 40 entries, 0 to 39
Data columns (total 12 columns):# Column Non-Null Count Dtype
--- ------ -------------- ----- 0 標題 40 non-null object1 BV號 40 non-null object2 分享 40 non-null int64 3 彈幕量 40 non-null int64 4 投幣 40 non-null int64 5 播放量 40 non-null int64 6 收藏 40 non-null int64 7 時長 40 non-null int64 8 時間 40 non-null object9 點贊 40 non-null int64 10 評論 40 non-null int64 11 鏈接 40 non-null object
dtypes: int64(8), object(4)
memory usage: 3.9+ KB
for col
in df_100
:print('column {} 包含 {} 個缺失值'.format(col
, df_100
[col
].isna
().sum()))
column 期數 包含 0 個缺失值
column 標題 包含 0 個缺失值
column up主 包含 0 個缺失值
column 播放量 包含 0 個缺失值
column 點贊 包含 0 個缺失值
column 視頻標簽 包含 46 個缺失值
column 視頻鏈接 包含 0 個缺失值
df_100
[df_100
['視頻標簽'].isna
().values
==True].head
(5)
期數標題up主播放量點贊視頻標簽視頻鏈接
2| 第1期 | 【性轉版】回家的誘惑(劉亦菲/劉昊然/鄧倫/吳磊/賈玲) | 蘭徹lancche | 405.5萬 | 4.1萬 | NaN | https://www.bilibili.com/video/BV1xb411n7L6 |
4| 第1期 | 哆啦A夢結局背后的秘密?從未播出的黑歷史?真相出人意料 | 瓶子君152 | 214.9萬 | 4440 | NaN | https://www.bilibili.com/video/BV1Qb41177Vm |
6| 第1期 | 在中國挑戰通宵賣燒烤!為啥美國沒有這個? | 我是郭杰瑞 | 228.4萬 | 1.3萬 | NaN | https://www.bilibili.com/video/BV1Rb411E7yi |
7| 第1期 | 腦瓜崩神器彈老外!耿哥出品,必屬精品! | 毒角SHOW | 172.8萬 | 3081 | NaN | https://www.bilibili.com/video/BV1ob411E7YH |
8| 第1期 | 【純黑】《鬼泣5》一周目無傷S評價攻略解說 第七期 | -純黑- | 126.9萬 | 5551 | NaN | https://www.bilibili.com/video/BV1Cb41147EK |
for col
in df_he
:print('column {} 包含 {} 個缺失值'.format(col
, df_he
[col
].isna
().sum()))
column 標題 包含 0 個缺失值
column BV號 包含 0 個缺失值
column 分享 包含 0 個缺失值
column 彈幕量 包含 0 個缺失值
column 投幣 包含 0 個缺失值
column 播放量 包含 0 個缺失值
column 收藏 包含 0 個缺失值
column 時長 包含 0 個缺失值
column 時間 包含 0 個缺失值
column 點贊 包含 0 個缺失值
column 評論 包含 0 個缺失值
column 鏈接 包含 0 個缺失值
pd
.set_option
('display.float_format',lambda x
: '%.2f' % x
)
df_he
.describe
()
分享彈幕量投幣播放量收藏時長點贊評論
count| 40.00 | 40.00 | 40.00 | 40.00 | 40.00 | 40.00 | 40.00 | 40.00 |
mean| 45431.07 | 32717.47 | 414634.85 | 4528813.97 | 133628.05 | 460.48 | 451989.55 | 14110.00 |
std| 86267.84 | 45473.10 | 578915.05 | 4638356.48 | 197777.93 | 362.53 | 544610.08 | 29499.88 |
min| 832.00 | 845.00 | 3895.00 | 569871.00 | 2402.00 | 118.00 | 18524.00 | 415.00 |
25%| 2381.25 | 2483.00 | 21690.25 | 1225498.50 | 12283.25 | 290.00 | 43864.00 | 1160.25 |
50%| 15491.50 | 8323.50 | 95782.00 | 2759189.00 | 41353.50 | 389.00 | 140839.00 | 3035.00 |
75%| 54696.00 | 51157.50 | 624656.00 | 6716039.25 | 188840.75 | 498.00 | 752161.00 | 15353.75 |
max| 514740.00 | 215661.00 | 2366963.00 | 25215096.00 | 924742.00 | 2082.00 | 2203659.00 | 178829.00 |
3.統計分析
3.1 上榜作品數 Top50 up主
print('一共的{}個up主'.format(df_100
['up主'].nunique
()))
一共的1040個up主
up_T50
= df_100
['up主'].value_counts
()[:50]
up_T50
涼風Kaze 64
老番茄 60
LexBurner 47
手工耿 36
朱一旦的枯燥生活 36
機智的黨妹 34
我是郭杰瑞 33
綿羊料理 32
羅翔說刑法 32
小潮院長 30
華農兄弟 30
硬核的半佛仙人 30
某幻君 30
敬漢卿 28
盜月社食遇記 22
央視新聞 21
中國BOY超級大猩猩 21
共青團中央 21
敖廠長 20
翔翔大作戰 19
木魚水心 19
靠譜電競 19
泛式 18
觀察者網 17
大祥哥來了 17
小片片說大片 17
花少北丶 16
畢導THU 15
啊嗎粽 15
東尼ookii 15
老師好我叫何同學 15
努力的Lorre 14
李子柒 13
英雄聯盟 12
鶴吱菌 12
記錄生活的蛋黃派 11
吃素的獅子 10
徐大sao 10
羅漢解說 10
徐大蝦咯 10
滲透之C君 10
瓶子君152 9
花花與三貓CatLive 9
納豆奶奶 9
嗶哩嗶哩英雄聯盟賽事 8
才疏學淺的才淺 8
神奇的老皮VFX 8
大家的音樂姬 8
老壇胡說 8
嗶哩嗶哩彈幕網 8
Name: up主, dtype: int64
bar1
= (Bar
().add_xaxis
(up_T50
.index
.tolist
()).add_yaxis
('',up_T50
.values
.tolist
(),color
='#62A39F').set_global_opts
(title_opts
= opts
.TitleOpts
(title
='上榜作品數 Top50 up主'),yaxis_opts
=opts
.AxisOpts
(name
='上榜作品數量'),xaxis_opts
=opts
.AxisOpts
(name
='up主'),datazoom_opts
=[opts
.DataZoomOpts
(), opts
.DataZoomOpts
(type_
='inside')],).set_series_opts
(label_opts
=opts
.LabelOpts
(is_show
=True),markpoint_opts
=opts
.MarkPointOpts
(data
=[opts
.MarkPointItem
(type_
='max', name
='最大值'),opts
.MarkPointItem
(type_
='min', name
='最小值'),opts
.MarkPointItem
(type_
='average', name
='平均值'),]),)
)
bar1
.render_notebook
()
3.2 up主熱門推薦視頻數占比
works
= df_100
['up主'].value_counts
()
works
涼風Kaze 64
老番茄 60
LexBurner 47
手工耿 36
朱一旦的枯燥生活 36..
1818黃金眼 1
自動鬼畜中的WZ 1
我在旺角殺左人 1
淘米睡起床了 1
花尹昭- 1
Name: up主, Length: 1040, dtype: int64
works
.index
Index(['涼風Kaze', '老番茄', 'LexBurner', '手工耿', '朱一旦的枯燥生活', '機智的黨妹', '我是郭杰瑞','綿羊料理', '羅翔說刑法', '小潮院長',...'陌然MajorC', '冰糖葫蘆沒放鹽', '藍書愛喝水', '馮提莫', '深夜徐老師', '1818黃金眼', '自動鬼畜中的WZ','我在旺角殺左人', '淘米睡起床了', '花尹昭-'],dtype='object', length=1040)
pie_1
= (Pie
().add
('',[list(z
) for z
in zip(up_T50
.index
.tolist
(), up_T50
.values
.tolist
())],radius
=['28%','60%'],center
=['35%','50%']).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='Top20 up主',pos_left
='28%',pos_top
='48%',title_textstyle_opts
=opts
.TextStyleOpts
(font_size
=20,font_weight
='bold')),legend_opts
=opts
.LegendOpts
(is_show
=False),visualmap_opts
=opts
.VisualMapOpts
(is_show
=False, min_
=9,max_
=329,is_piecewise
=False,dimension
=0,)).set_series_opts
(label_opts
=opts
.LabelOpts
(formatter
=':{c} vt6mr5x%'))
)
pie_1
.render_notebook
()
3.3 播放量區間統計
df_100
['播放量/萬'] = df_100
['播放量'].str.split
('萬').apply(lambda x
: x
[0])
df_100
['播放量/萬'] = df_100
['播放量/萬'].astype
(float).apply(lambda x
: round(x
,2))
df_100
['播放量/萬'].describe
()
count 2499.00
mean 460.93
std 403.16
min 12.20
25% 233.05
50% 359.90
75% 553.40
max 7449.60
Name: 播放量/萬, dtype: float64
def transform_plays(x
):if x
<= 100:return '小于100萬'elif x
<= 200:return '100—200萬'elif x
<= 300:return '200—300萬'elif x
<= 400:return '300—400萬'elif x
<= 500:return '400—500萬'elif x
<= 600:return '500—600萬'elif x
<= 700:return '600—700萬'else:return '700萬以上'
df_100
['播放量(區間)'] = df_100
['播放量/萬'].apply(lambda x
: transform_plays
(x
))
play
= df_100
['播放量(區間)'].value_counts
()
sort_list
= ['小于100萬','100—200萬','200—300萬','300—400萬','400—500萬','500—600萬','600—700萬','700萬以上']
play
= play
.loc
[sort_list
]
play
小于100萬 57
100—200萬 392
200—300萬 524
300—400萬 428
400—500萬 329
500—600萬 225
600—700萬 156
700萬以上 388
Name: 播放量(區間), dtype: int64
bar_1
= (Bar
().add_xaxis
(play
.index
.tolist
()).add_yaxis
('視頻數量',play
.values
.tolist
(),color
='#62A39F',label_opts
=opts
.LabelOpts
(is_show
=True,position
='top')).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='播放量區間統計'),xaxis_opts
=opts
.AxisOpts
(name
='播放量區間',type_
='category',axislabel_opts
={"interval":"0"}),yaxis_opts
=opts
.AxisOpts
(name
='視頻數量',min_
=0,max_
=550,splitline_opts
=opts
.SplitLineOpts
(is_show
=True,linestyle_opts
=opts
.LineStyleOpts
(type_
='dash'),)),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross'))
)bar_1
.render_notebook
()
3.4 點贊量區間分布
df_100
['點贊'] = df_100
['點贊'].apply(lambda x
: str(int(x
)/10000)+'萬' if '萬' not in x
else x
)
df_100
['點贊/萬'] = df_100
['點贊'].str.split
('萬').apply(lambda x
: x
[0])
df_100
['點贊/萬'] = df_100
['點贊/萬'].astype
(float).apply(lambda x
:round(x
,2))
df_100
['點贊/萬'].describe
()
count 2499.00
mean 3.37
std 5.57
min 0.00
25% 0.89
50% 1.90
75% 3.90
max 153.60
Name: 點贊/萬, dtype: float64
def transform_likes(x
):if x
<= 2:return '小于2萬'elif x
<= 4:return '2—4萬'elif x
<= 6:return '4—6萬'elif x
<= 8:return '6—8萬'elif x
<= 10:return '8—10萬'elif x
<= 12:return '10—12萬'elif x
<= 14:return '12—14萬'elif x
<= 16:return '14—16萬'elif x
<= 18:return '16—18萬'elif x
<= 20:return '18—20萬'else:return '20萬以上'
df_100
['點贊(區間)'] = df_100
['點贊/萬'].apply(lambda x
:transform_likes
(x
))
like
= df_100
['點贊(區間)'].value_counts
()
like
小于2萬 1324
2—4萬 580
4—6萬 257
6—8萬 121
8—10萬 73
10—12萬 38
20萬以上 36
12—14萬 28
14—16萬 20
16—18萬 12
18—20萬 10
Name: 點贊(區間), dtype: int64
sort_list
= ['小于2萬','2—4萬','4—6萬','6—8萬','8—10萬','10—12萬','12—14萬','14—16萬','16—18萬','18—20萬','20萬以上']
like
= like
.loc
[sort_list
]
like
小于2萬 1324
2—4萬 580
4—6萬 257
6—8萬 121
8—10萬 73
10—12萬 38
12—14萬 28
14—16萬 20
16—18萬 12
18—20萬 10
20萬以上 36
Name: 點贊(區間), dtype: int64
bar_2
= (Bar
().add_xaxis
(like
.index
.tolist
()).add_yaxis
('點贊數',like
.values
.tolist
(),color
='#62A39F',label_opts
=opts
.LabelOpts
(is_show
=True,position
='top',)).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='點贊數量區間統計'),xaxis_opts
=opts
.AxisOpts
(name
='點贊量區間',type_
='category',axislabel_opts
={"interval":"0"}),yaxis_opts
=opts
.AxisOpts
(name
='點贊數量',min_
=0,max_
=550,splitline_opts
=opts
.SplitLineOpts
(is_show
=True,linestyle_opts
=opts
.LineStyleOpts
(type_
='dash'),)),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross'))
)bar_2
.render_notebook
()
3.5 最受歡迎的作品 top20
df_100
.head
(3)
期數標題up主播放量點贊視頻標簽視頻鏈接播放量/萬播放量(區間)點贊/萬點贊(區間)
0| 第1期 | 這集vlog我們拍了十年,致最美好的青春 | AresserA-Vlog | 438.9萬 | 6.6萬 | 暴風流淚推薦!今天也是為別人的神仙愛情流淚的一天! | https://www.bilibili.com/video/BV14b411J7ML | 438.90 | 400—500萬 | 6.60 | 6—8萬 |
1| 第1期 | 華農兄弟:兄弟家的魚跑河里去了,幫他網回來,一網下去還不少 | 華農兄弟 | 240.5萬 | 2.1萬 | 村霸兄弟又上線了!這次他們把魔抓伸向了兄弟家的魚! | https://www.bilibili.com/video/BV15b41147uu | 240.50 | 200—300萬 | 2.10 | 2—4萬 |
2| 第1期 | 【性轉版】回家的誘惑(劉亦菲/劉昊然/鄧倫/吳磊/賈玲) | 蘭徹lancche | 405.5萬 | 4.1萬 | NaN | https://www.bilibili.com/video/BV1xb411n7L6 | 405.50 | 400—500萬 | 4.10 | 4—6萬 |
df_100
= df_100
.sort_values
(by
=['播放量/萬','點贊/萬'], ascending
=False)
df_100
['播放量/百萬'] = df_100
['播放量/萬'].apply(lambda x
: x
/100).apply(lambda x
: round(x
,2))
df_100
['點贊播放比'] = df_100
.apply(lambda x
: round(x
['點贊/萬']/x
['播放量/萬']*100, 2), axis
=1)
df_100
.head
(3)
期數標題up主播放量點贊視頻標簽視頻鏈接播放量/萬播放量(區間)點贊/萬點贊(區間)播放量/百萬點贊播放比
843| 第45期 | 【嗶哩嗶哩2020拜年祭】 | 嗶哩嗶哩拜年紀 | 7449.6萬 | 153.6萬 | 十年B站,一如既往 | https://www.bilibili.com/video/BV1TJ411C7An | 7449.60 | 700萬以上 | 153.60 | 20萬以上 | 74.50 | 2.06 |
263| 第19期 | 【派大星的獨白】一個關于正常人的故事 | 洛溫阿特金森 | 5688.3萬 | 34.3萬 | 歡樂是如何消失的呢,海綿寶寶? | https://www.bilibili.com/video/BV1qt411j7fV | 5688.30 | 700萬以上 | 34.30 | 20萬以上 | 56.88 | 0.60 |
1302| 第61期 | 最 強 法 海 | 推背兔の | 4231.1萬 | 12.9萬 | 原來是電音寺法海啊 | https://www.bilibili.com/video/BV1pi4y147tQ | 4231.10 | 700萬以上 | 12.90 | 12—14萬 | 42.31 | 0.30 |
bar_3
= (Bar
(init_opts
=opts
.InitOpts
(theme
=ThemeType
.PURPLE_PASSION
,height
='500px',width
='1000px')).add_xaxis
(df_100
[:20]['標題']).add_yaxis
('播放量/百萬',y_axis
=df_100
[:20]['播放量/萬'].to_list
(),yaxis_index
=0,label_opts
=opts
.LabelOpts
(is_show
=False),stack
='stack1',color
='#E76278').add_yaxis
('點贊/萬',y_axis
=df_100
[:20]['點贊/萬'].tolist
(),yaxis_index
=0,label_opts
=opts
.LabelOpts
(is_show
=False),stack
='stack1',color
='#712164').extend_axis
(yaxis
=opts
.AxisOpts
(name
='點贊播放百分比',min_
=-3,max_
=3,position
='right',axisline_opts
=opts
.AxisLineOpts
(linestyle_opts
=opts
.LineStyleOpts
(color
='#712164')),axislabel_opts
=opts
.LabelOpts
(formatter
='{value} %'))).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='B站熱門綜合視頻Top20'),xaxis_opts
=opts
.AxisOpts
(name
='',type_
='category',name_gap
=35,axislabel_opts
=opts
.LabelOpts
(interval
=0, rotate
=30),),yaxis_opts
=opts
.AxisOpts
(name
='',splitline_opts
=opts
.SplitLineOpts
(is_show
=True),axislabel_opts
=opts
.LabelOpts
(formatter
='{value}萬')),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross'))
)
line_1
= (Line
().add_xaxis
(df_100
[:20]['標題']).add_yaxis
('點贊播放比',y_axis
=df_100
[:20]['點贊播放比'].tolist
(),label_opts
=opts
.LabelOpts
(is_show
=False),symbol
='emptyCircle',is_symbol_show
=True,color
='#712164',yaxis_index
=1)
)
bar_3
.overlap
(line_1
).render_notebook
()
3.6 累計播放量Top20(按up主)
play_count
= df_100
.groupby
('up主')['播放量/萬'].sum().sort_values
(ascending
=False).astype
(int)
play_count
up主
老番茄 52962
涼風Kaze 31576
LexBurner 25165
小潮院長 21813
敬漢卿 19991...
鬼畜↑可樂♂ 33
豆豆班主任 30
妃說電影 20
我在降妖現場呢 19
1818黃金眼 16
Name: 播放量/萬, Length: 1040, dtype: int32
like_count
= df_100
.groupby
('up主')['點贊/萬'].sum().sort_values
(ascending
=False).astype
(int)
like_count
up主
老番茄 467
涼風Kaze 322
LexBurner 204
敬漢卿 192
某幻君 181...
豆豆班主任 0
走x琛 0
壹直設計 0
妃說電影 0
哈百里 0
Name: 點贊/萬, Length: 1040, dtype: int32
df_play
= pd
.DataFrame
(play_count
)
df_like
= pd
.DataFrame
(like_count
)
print(df_play
)
print(df_like
)
播放量/萬
up主
老番茄 52962.40
涼風Kaze 31576.30
LexBurner 25165.50
小潮院長 21814.00
敬漢卿 19991.50
... ...
鬼畜↑可樂♂ 33.30
豆豆班主任 30.10
妃說電影 20.80
我在降妖現場呢 19.70
1818黃金眼 16.10[1040 rows x 1 columns]點贊/萬
up主
老番茄 467.00
涼風Kaze 322.75
LexBurner 204.20
敬漢卿 192.96
某幻君 181.90
... ...
豆豆班主任 0.05
走x琛 0.05
壹直設計 0.04
妃說電影 0.04
哈百里 0.01[1040 rows x 1 columns]
- 累計點贊和累計播放數量相差太大, 不太好放在一張圖里
play_like_count
= pd
.merge
(play_count
,like_count
,on
='up主')
play_like_count
['點贊播放比'] = play_like_count
.apply(lambda x
: round(x
['點贊/萬']/x
['播放量/萬']*100,2),axis
=1)
play_like_count
播放量/萬點贊/萬點贊播放比
up主
老番茄| 52962.40 | 467.00 | 0.88 |
涼風Kaze| 31576.30 | 322.75 | 1.02 |
LexBurner| 25165.50 | 204.20 | 0.81 |
小潮院長| 21814.00 | 149.50 | 0.69 |
敬漢卿| 19991.50 | 192.96 | 0.97 |
...| ... | ... | ... |
鬼畜↑可樂♂| 33.30 | 0.12 | 0.36 |
豆豆班主任| 30.10 | 0.05 | 0.17 |
妃說電影| 20.80 | 0.04 | 0.19 |
我在降妖現場呢| 19.70 | 0.33 | 1.68 |
1818黃金眼| 16.10 | 0.18 | 1.12 |
1040 rows × 3 columns
bar_4
= (Bar
().add_xaxis
(play_count
.index
[:20].tolist
()).add_yaxis
('播放量/萬',play_count
.values
[:20].tolist
(),color
='#62A39F',label_opts
=opts
.LabelOpts
(is_show
=True,position
='top'),).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='累計播放量Top20(按up主)'),xaxis_opts
=opts
.AxisOpts
(name
='up主',type_
='category',axislabel_opts
=opts
.LabelOpts
(rotate
=45),),yaxis_opts
=opts
.AxisOpts
(name
='',splitline_opts
=opts
.SplitLineOpts
(is_show
=True,linestyle_opts
=opts
.LineStyleOpts
(type_
='dash'))),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross')).set_series_opts
(markline_opts
=opts
.MarkLineOpts
(data
=[opts
.MarkLineItem
(type_
='average',name
='均值'),opts
.MarkLineItem
(type_
='max',name
='最大值'),opts
.MarkLineItem
(type_
='min',name
='最小值'),],linestyle_opts
=opts
.LineStyleOpts
(color
='#35AAA0',type_
='dash')))
)bar_4
.render_notebook
()
3.7 累計點贊量Top20(按up主)
bar_5
= (Bar
().add_xaxis
(like_count
.index
[:20].tolist
()).add_yaxis
('點贊/萬',like_count
.values
[:20].tolist
(),color
='#62A39F',label_opts
=opts
.LabelOpts
(is_show
=True,position
='top'),).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='累計點贊Top20(按up主)'),xaxis_opts
=opts
.AxisOpts
(name
='up主',type_
='category',axislabel_opts
=opts
.LabelOpts
(rotate
=45),),yaxis_opts
=opts
.AxisOpts
(name
='',splitline_opts
=opts
.SplitLineOpts
(is_show
=True,linestyle_opts
=opts
.LineStyleOpts
(type_
='dash'))),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross')).set_series_opts
(markline_opts
=opts
.MarkLineOpts
(data
=[opts
.MarkLineItem
(type_
='average',name
='均值'),opts
.MarkLineItem
(type_
='max',name
='最大值'),opts
.MarkLineItem
(type_
='min',name
='最小值'),],linestyle_opts
=opts
.LineStyleOpts
(color
='#35AAA0',type_
='dash')))
)bar_5
.render_notebook
()
3.8 點贊播放比Top20(按up主)
play_like_count
['點贊播放比'].sort_values
(ascending
=False)
up主
思維跳躍的熊怪 15.80
觀學院官方 7.96
GoldenEggs 6.93
嗶哩嗶哩UP主執事 5.17
bilibili星訪問 4.91...
sekaiの光子 0.04
小島鴿手 0.04
滾滾不是廣坤 0.02
走x琛 0.02
哈百里 0.00
Name: 點贊播放比, Length: 1040, dtype: float64
bar_5
= (Bar
().add_xaxis
(play_like_count
['點贊播放比'].sort_values
(ascending
=False).index
[:20].tolist
()).add_yaxis
('點贊播放比',play_like_count
['點贊播放比'].sort_values
(ascending
=False).values
[:20].tolist
(),color
='#62A39F',label_opts
=opts
.LabelOpts
(is_show
=True,position
='top'),).set_global_opts
(title_opts
=opts
.TitleOpts
(title
='點贊播放比Top20(按up主)'),xaxis_opts
=opts
.AxisOpts
(name
='up主',type_
='category',axislabel_opts
=opts
.LabelOpts
(rotate
=45),),yaxis_opts
=opts
.AxisOpts
(name
='',splitline_opts
=opts
.SplitLineOpts
(is_show
=True,linestyle_opts
=opts
.LineStyleOpts
(type_
='dash'))),tooltip_opts
=opts
.TooltipOpts
(trigger
='axis',axis_pointer_type
='cross')).set_series_opts
(markline_opts
=opts
.MarkLineOpts
(data
=[opts
.MarkLineItem
(type_
='average',name
='均值'),opts
.MarkLineItem
(type_
='max',name
='最大值'),opts
.MarkLineItem
(type_
='min',name
='最小值'),],linestyle_opts
=opts
.LineStyleOpts
(color
='#35AAA0',type_
='dash')))
)bar_5
.render_notebook
()
總結
以上是生活随笔為你收集整理的[Pyecharts 可视化] B站推荐视频分析的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。