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
='{b}:{c} {d}%'))
)
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站推荐视频分析的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。