-
Notifications
You must be signed in to change notification settings - Fork 19
/
4.3-全区粉丝响应指数TOP10视频.py
55 lines (46 loc) · 1.69 KB
/
4.3-全区粉丝响应指数TOP10视频.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pandas as pd
import os
import pyecharts.options as opts
from pyecharts.charts import Bar
import numpy as np
def draw_line(xlist, ylist):
c = (
Bar(init_opts=opts.InitOpts(
width='1800px',
height='900px',
js_host="./",
))
.add_xaxis(xlist)
.add_yaxis("粉丝响应指数", ylist)
.set_global_opts(
title_opts=opts.TitleOpts("知识区TOP10粉丝响应指数视频"),
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
brush_opts=opts.BrushOpts(),
)
.render('./柱状图/知识区TOP10粉丝响应指数视频.html')
)
if __name__ == '__main__':
fansfile = pd.read_csv('up主粉丝数.csv', encoding='gb18030')
dict_country = fansfile.set_index('uid').T.to_dict('list')
namelist = []
numlist = []
files = os.listdir('./源数据/')
for file in files:
data = pd.read_csv('./源数据/' + file, encoding='gb18030')
for i in range(0, len(data)):
namelist.append(data['名称'].iloc[i])
a = dict_country[data['up主id'].iloc[i]][1]
if '万' in str(data['播放量'].iloc[i]):
b = int(float(str(data['播放量'].iloc[i]).split('万')[0]) * 10000)
else:
b = int(data['播放量'].iloc[i])
c = round(b / a , 2)
numlist.append(c)
nnum = np.array(numlist)
snum = np.argsort(nnum)
xlist = []
ylist = []
for i in range(1, 11):
xlist.append(namelist[snum[0 - i]])
ylist.append(numlist[snum[0 - i]])
draw_line(xlist, ylist)