最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python Pandas工具繪制數(shù)據(jù)圖使用教程

 更新時(shí)間:2021年12月01日 08:49:18   作者:小旺不正經(jīng)  
Pandas是基于NumPy 的一種工具,該工具是為解決數(shù)據(jù)分析任務(wù)而創(chuàng)建的。Pandas還可以繪制多重?cái)?shù)據(jù)圖表,本文將為大家介紹如何通過(guò)Pandas繪制圖表,感興趣的可以了解一下

背景介紹

Pandas的DataFrame和Series在Matplotlib基礎(chǔ)上封裝了一個(gè)簡(jiǎn)易的繪圖函數(shù),使得數(shù)據(jù)處理過(guò)程中方便可視化查看結(jié)果。

折線(xiàn)圖

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=[1,2])
df.plot()
plt.show()

條形圖

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=[1,2])
df.plot(kind='bar')
plt.show()

水平條形圖

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=[1,2])
df.plot(kind='barh')
plt.show()

堆積圖

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=[1,2])
df.plot(kind='bar',stacked=True)
plt.show()

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=[1,2])
df.plot(kind='barh',stacked=True)
plt.show()

散點(diǎn)圖

數(shù)據(jù)通常是一些點(diǎn)的集合

常用來(lái)繪制各種相關(guān)性,適合研究不同變量間的關(guān)系

  • x:x坐標(biāo)位置
  • y:y坐標(biāo)位置
  • s:散點(diǎn)的大小
  • c:散點(diǎn)顏色
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=np.random.randn(5,2)*10
df=pd.DataFrame(np.abs(data),index=[1,2,3,4,5],columns=['A','B'])
df.plot(kind='scatter',x='A',y='B',s=df.A*100,c='red')
plt.show()

餅圖

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.Series(3*np.random.rand(4),index=['a','b','c','d'])
df.plot.pie(figsize=(6,6))
plt.show()

蜂巢圖

體現(xiàn)數(shù)據(jù)出現(xiàn)的次數(shù)

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.DataFrame(np.random.randn(1000,2),columns=['a','b'])
df.plot.hexbin(x='a',y='b',sharex=False,gridsize=30)
plt.show()

箱線(xiàn)圖

基于最小值、上四分位、中位數(shù)、下四分位和最大值5個(gè)數(shù)值特征展示數(shù)據(jù)分布的標(biāo)準(zhǔn)方式,可以看出數(shù)據(jù)是否具有對(duì)稱(chēng)性,適用于展示一組數(shù)據(jù)的分布情況

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.DataFrame(np.random.randn(1000,2),columns=['a','b'])
df.plot(y=df.columns,kind='box',vert=False)
plt.show()

繪制子圖

subplots:默認(rèn)False 若每列繪制子圖就為T(mén)rue

layout:子圖布局

figsize:畫(huà)布大小

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.DataFrame(np.random.randn(5,2),columns=['a','b'])
df.plot(subplots=True,layout=(2,3),figsize=(10,10),kind='bar')
plt.show()

以上就是Python Pandas工具繪制數(shù)據(jù)圖使用教程的詳細(xì)內(nèi)容,更多關(guān)于Python Pandas 繪制圖的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • python實(shí)現(xiàn)web方式logview的方法

    python實(shí)現(xiàn)web方式logview的方法

    這篇文章主要介紹了python實(shí)現(xiàn)web方式logview的方法,涉及Python基于web模塊操作Linux命令的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-08-08
  • Python實(shí)現(xiàn)byte轉(zhuǎn)integer

    Python實(shí)現(xiàn)byte轉(zhuǎn)integer

    這篇文章主要介紹了Python實(shí)現(xiàn)byte轉(zhuǎn)integer操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • Python?Pandas聚合函數(shù)的應(yīng)用示例

    Python?Pandas聚合函數(shù)的應(yīng)用示例

    Pandas是當(dāng)前Python數(shù)據(jù)分析中最為重要的工具,其提供了功能強(qiáng)大且靈活多樣的API,可以滿(mǎn)足使用者在數(shù)據(jù)分析和處理中的多種選擇和實(shí)現(xiàn)方式,下面這篇文章主要給大家介紹了關(guān)于Python?Pandas聚合函數(shù)的相關(guān)資料,需要的朋友可以參考下
    2022-07-07
  • Python使用scrapy采集數(shù)據(jù)時(shí)為每個(gè)請(qǐng)求隨機(jī)分配user-agent的方法

    Python使用scrapy采集數(shù)據(jù)時(shí)為每個(gè)請(qǐng)求隨機(jī)分配user-agent的方法

    這篇文章主要介紹了Python使用scrapy采集數(shù)據(jù)時(shí)為每個(gè)請(qǐng)求隨機(jī)分配user-agent的方法,涉及Python使用scrapy采集數(shù)據(jù)的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-04-04
  • Python importlib模塊重載使用方法詳解

    Python importlib模塊重載使用方法詳解

    這篇文章主要介紹了Python importlib模塊重載使用方法詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-10-10
  • Pytorch實(shí)現(xiàn)邏輯回歸分類(lèi)

    Pytorch實(shí)現(xiàn)邏輯回歸分類(lèi)

    這篇文章主要為大家詳細(xì)介紹了Pytorch實(shí)現(xiàn)邏輯回歸分類(lèi),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • python中partial庫(kù)的使用方法解析

    python中partial庫(kù)的使用方法解析

    這篇文章主要介紹了python中partial庫(kù)的使用方法解析,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-08-08
  • python中的不可變數(shù)據(jù)類(lèi)型與可變數(shù)據(jù)類(lèi)型詳解

    python中的不可變數(shù)據(jù)類(lèi)型與可變數(shù)據(jù)類(lèi)型詳解

    探尋python的數(shù)據(jù)類(lèi)型是否可變,也可以更好的理解python對(duì)內(nèi)存的使用情況,下面這篇文章主要給大家介紹了關(guān)于python中不可變數(shù)據(jù)類(lèi)型與可變數(shù)據(jù)類(lèi)型的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2018-09-09
  • python可視化分析繪制散點(diǎn)圖和邊界氣泡圖

    python可視化分析繪制散點(diǎn)圖和邊界氣泡圖

    這篇文章主要介紹了python可視化分析繪制散點(diǎn)圖和邊界氣泡圖,python繪制散點(diǎn)圖,展現(xiàn)兩個(gè)變量間的關(guān)系,當(dāng)數(shù)據(jù)包含多組時(shí),使用不同顏色和形狀區(qū)分
    2022-06-06
  • Python文件時(shí)間操作步驟代碼詳解

    Python文件時(shí)間操作步驟代碼詳解

    這篇文章主要介紹了Python文件時(shí)間操作步驟代碼詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04

最新評(píng)論

滁州市| 罗定市| 阿坝| 广东省| 利津县| 宁安市| 卢湾区| 马鞍山市| 吉林市| 清新县| 澄城县| 冷水江市| 积石山| 固安县| 墨江| 台东县| 灵寿县| 芮城县| 广宗县| 台南县| 平湖市| 湘西| 长沙市| 铜鼓县| 临清市| 南平市| 武鸣县| 桦川县| 弥渡县| 旺苍县| 湛江市| 宣城市| 嵩明县| 阿巴嘎旗| 濉溪县| 凯里市| 芒康县| 丘北县| 揭阳市| 武宣县| 嵊泗县|