


本期为知乎热榜/微博热搜时序图>系列文章下篇 Content, [Part 1] introduces you how to use Python to regularly crawl Zhihu hot list/Weibo hot search data. Today will introduce to you how to use pyecharts to create a time series chart of hot list data. (Dynamic carousel chart) , I hope it will be helpful to you.
Let’s take a look at the effect first (different playback speeds):


names = ['詹姆斯', '杜兰特', '库里', '欧文', '哈登'] allinfo = [[[492, 610, 533, 416, 565, 639, 709, 465, 472], [387, 551, 488, 511, 514, 646, 747, 454, 636], [1683, 2036, 2089, 1743, 1920, 1954, 2251, 1505, 1544]], [[533, 527, 640, 598, 178, 589, 513, 464, 497], [214, 231, 374, 445, 110, 361, 300, 366, 457], [2161, 1850, 2280, 2593, 686, 2029, 1555, 1792, 2027]], [[88, 314, 334, 341, 430, 353, 261, 369, 26], [138, 539, 666, 619, 527, 524, 310, 361, 33], [383, 1786, 1873, 1900, 2375, 1999, 1346, 1881, 104]], [[191, 216, 259, 237, 157, 230, 227, 335, 103], [275, 350, 433, 389, 250, 418, 306, 464, 128], [944, 1325, 1478, 1628, 1041, 1816, 1466, 1596, 548]], [[252, 379, 344, 459, 501, 659, 389, 518, 387], [229, 455, 446, 565, 612, 907, 630, 586, 450], [1044, 2023, 1851, 2217, 2376, 2356, 2191, 2818, 2096]]]
The data comes from a previous article:
["James" ranks first in NBA official jersey sales list , quickly see where your idol ranks 】
时序图代码:
y1 = [] y2 = [] y3 = [] for i in range(9): y_trb_sorce = [] y_ast_sorce = [] y_pts_sorce = [] for j in range(5): y_trb_sorce.append(allinfo[j][0][i]) y_ast_sorce.append(allinfo[j][1][i]) y_pts_sorce.append(allinfo[j][2][i]) y1.append(y_pts_sorce) y2.append(y_ast_sorce) y3.append(y_trb_sorce) years = ['11-12赛季', '12-13赛季', '13-14赛季', '14-15赛季', '15-16赛季', '16-17赛季', '17-18赛季', '18-19赛季', '19-20赛季'] tl = Timeline() for i in range(9): bar = ( Bar() .add_xaxis(names) .add_yaxis('得分', y1[i]) .add_yaxis('助攻', y2[i]) .add_yaxis('篮板', y3[i]) .set_global_opts(title_opts=opts.TitleOpts("{}三项数据".format(years[i]))) ) tl.add(bar, "{}".format(years[i])) tl.render_notebook()

2.1 Reading data
weibo_data = pd.read_csv('weibo_hot_datas.csv') weibo_data.head()

2.2 排名前15的热点
代码:
tl = Timeline() count = 50 time_data_counts = int(weibo_data.shape[0]/count) times = weibo_data['时间'].values.tolist() for i in range(time_data_counts): bar = ( Bar() .add_xaxis(list(weibo_data['标题'])[i*count:i*count+15][::-1]) .add_yaxis('微博热搜', list(weibo_data['热度'])[i*count:i*count+15][::-1]) .reversal_axis() .set_global_opts(title_opts=opts.TitleOpts('{}'.format(times[i*count]))) ) tl.add(bar, "{}".format(times[i*count])) tl.render_notebook()
2.3 调整边距
代码:
# 将图形整体右移 grid = ( Grid() .add(bar, grid_opts=opts.GridOpts(pos_left='30%', pos_right='10%')) ) tl.add(bar, "{}".format(times[i*count])) tl.add(grid, '')
2.4 定制主题,增加图标,设置播放速度
Effect:

zhihu_data = pd.read_csv('zhuhu_hot_datas.csv') zhihu_data.head()
##3.2 Top 15 Hotspots
Effect:
##3.3 Ranking The hot spots of the last 15
## Effect:This issue is mainly to provide friends with an idea for making sequence diagrams. There are many code repetitions, and the Zhihu hot list code is not posted. It's out. If you need it, you can check the code at the link below (Part 1, Part 2), or you can Running online: https://www.heywhale.com/mw/project/60dd1932ee16460017a49d57
The above is the detailed content of Crawler + Visualization | Python Zhihu Hot List/Weibo Hot Search Sequence Chart (Part 2). For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor

Zend Studio 13.0.1
Powerful PHP integrated development environment
