国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
python爬蟲28 | 你爬下的數(shù)據(jù)不分析一波可就虧了啊,使用python進(jìn)行數(shù)據(jù)可視化

通過這段時(shí)間

小帥b教你從抓包開始

到數(shù)據(jù)爬取

到數(shù)據(jù)解析

再到數(shù)據(jù)存儲(chǔ)

相信你已經(jīng)能抓取大部分你想爬取的網(wǎng)站數(shù)據(jù)了

恭喜恭喜

但是

數(shù)據(jù)抓取下來(lái)

要好好分析一波

最好的方式就是把數(shù)據(jù)進(jìn)行可視化

這樣才能直觀的感受到數(shù)據(jù)的魅力

不過有一點(diǎn)

現(xiàn)在市面上可以使用 python 的可視化庫(kù)多如牛毛

各有各的優(yōu)點(diǎn)

接下來(lái)小帥b把自己常用的一些可視化數(shù)據(jù)庫(kù)分享給你

好不?

那么

接下來(lái)就是

學(xué)習(xí) python 的正確姿勢(shì)

先來(lái)說(shuō)說(shuō)一個(gè)經(jīng)典的可視化庫(kù)

matplotlib

它是基于 NumPy 的一個(gè)數(shù)據(jù)可視化工具,內(nèi)置了非常多圖給我們使用

接下來(lái)我們就來(lái)玩玩吧

首先你得去下載一下這個(gè)庫(kù)

python -m pip install -U pip setuptoolspython -m pip install matplotlib

下載完之后

就可以來(lái)玩代碼啦

畫畫sin和cos線

import numpy as npimport .pyplot as plt
x = np.linspace(-np.pi, np.pi, 256)
cos = np.cos(x)sin = np.sin(x)
plt.plot(x, cos, '--', linewidth=2)plt.plot(x, sin)
plt.show()

畫個(gè)餅圖

# Pie chart, where the slices will be ordered and plotted counter-clockwise:labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'sizes = [15, 30, 45, 10]explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots()ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90)ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()

畫畫直方圖

import numpy as npimport matplotlib.pyplot as plt
np.random.seed(0)
mu = 200sigma = 25x = np.random.normal(mu, sigma, size=100)
fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4))
ax0.hist(x, 20, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75)ax0.set_title('stepfilled')
# Create a histogram by providing the bin edges (unequally spaced).bins = [100, 150, 180, 195, 205, 220, 250, 300]ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8)ax1.set_title('unequal bins')
fig.tight_layout()plt.show()

更多關(guān)于 matplotlib 的文檔可以到以下鏈接查看

https://matplotlib.org/2.0.2/contents.html

seaborn

seaborn 是基于 matplotlib 的庫(kù),所以有更加高級(jí)的接口給我們使用,相對(duì)來(lái)說(shuō)更加簡(jiǎn)單使用一些

畫個(gè)散點(diǎn)圖

import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snssns.set(style="darkgrid")

tips = sns.load_dataset("tips")sns.relplot(x="total_bill", y="tip", data=tips);plt.show()

畫個(gè)折線圖

fmri = sns.load_dataset("fmri")sns.relplot(x="timepoint", y="signal", hue="event", kind="line", data=fmri);plt.show()

畫個(gè)直方圖


titanic = sns.load_dataset("titanic")sns.catplot(x="sex", y="survived", hue="class", kind="bar", data=titanic);plt.show()

更多關(guān)于 seaborn 的可以看看以下鏈接

https://seaborn.pydata.org/index.html

pyecharts

這是基于百度開源的數(shù)據(jù)可視化的 echarts 的庫(kù)

echarts 遇上了 python 之后

就像巧克力遇上了音樂

絲滑~

特別是當(dāng) pyechart 結(jié)合  Notebook 的時(shí)候

簡(jiǎn)直不能在絲滑了

來(lái)畫個(gè)直方圖

from pyecharts.charts import Barfrom pyecharts import options as opts
bar = ( Bar() .add_xaxis(["襯衫", "毛衣", "領(lǐng)帶", "褲子", "風(fēng)衣", "高跟鞋", "襪子"]) .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105]) .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49]) .set_global_opts(title_opts=opts.TitleOpts(title="某商場(chǎng)銷售情況")))bar.render()

畫個(gè)餅圖

def pie_base() -> Pie: c = ( Pie() .add("", [list(z) for z in zip(Faker.choose(), Faker.values())]) .set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例")) .set_series_opts(label_opts=opts.LabelOpts(formatter=": {c}")) ) return c
# 需要安裝 snapshot_seleniummake_snapshot(driver, pie_base().render(), "pie.png")

再來(lái)畫個(gè)詞云圖

words = [ ("Sam S Club", 10000), ("Macys", 6181), ("Amy Schumer", 4386), ("Jurassic World", 4055), ("Charter Communications", 2467), ("Chick Fil A", 2244), ("Planet Fitness", 1868), ("Pitch Perfect", 1484), ("Express", 1112), ("Home", 865), ("Johnny Depp", 847), ("Lena Dunham", 582), ("Lewis Hamilton", 555), ("KXAN", 550), ("Mary Ellen Mark", 462), ("Farrah Abraham", 366), ("Rita Ora", 360), ("Serena Williams", 282), ("NCAA baseball tournament", 273), ("Point Break", 265),]

def wordcloud_base() -> WordCloud: c = ( WordCloud() .add("", words, word_size_range=[20, 100]) .set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-基本示例")) ) return c
# 需要安裝 snapshot_seleniummake_snapshot(driver, wordcloud_base().render(), "WordCloud.png")

是不是很絲滑

更多關(guān)于 pyecharts 的可以到以下鏈接看看

https://pyecharts.org

好了

以上就是小帥b常用到的幾個(gè)可視化數(shù)據(jù)庫(kù)

當(dāng)然

還有很多可視化數(shù)據(jù)庫(kù)

不過這幾個(gè)算是很友好的了

希望對(duì)你有用

那么

我們下回見

peace

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
數(shù)據(jù)分析入門系列教程-常用圖表
我用數(shù)據(jù)告訴你,家長(zhǎng)學(xué)歷對(duì)孩子成績(jī)的影響有多大?
學(xué)習(xí)Python數(shù)據(jù)可視化,看這篇就夠了
python數(shù)據(jù)可視化 | matplotlib.pyplot()函數(shù)繪制散點(diǎn)圖
python爬取拉勾網(wǎng)數(shù)據(jù)并進(jìn)行數(shù)據(jù)可視化
Python數(shù)據(jù)可視化工具測(cè)評(píng):5大工具誰(shuí)是第一?
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服