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

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

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

背景介紹

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

折線圖

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()

散點圖

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

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

  • x:x坐標(biāo)位置
  • y:y坐標(biāo)位置
  • s:散點的大小
  • c:散點顏色
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()

箱線圖

基于最小值、上四分位、中位數(shù)、下四分位和最大值5個數(shù)值特征展示數(shù)據(jù)分布的標(biāo)準(zhǔn)方式,可以看出數(shù)據(jù)是否具有對稱性,適用于展示一組數(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 若每列繪制子圖就為True

layout:子圖布局

figsize:畫布大小

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 繪制圖的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

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

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

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

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

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

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

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

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

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

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

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

    Pytorch實現(xiàn)邏輯回歸分類

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

    python中partial庫的使用方法解析

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

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

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

    python可視化分析繪制散點圖和邊界氣泡圖

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

    Python文件時間操作步驟代碼詳解

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

最新評論

犍为县| 开平市| 衡山县| 滨海县| 静宁县| 黄浦区| 西安市| 炉霍县| 米易县| 芜湖县| 罗城| 永胜县| 绍兴市| 达尔| 房产| 陵水| 南通市| 岳西县| 望奎县| 阿拉尔市| 稷山县| 晋中市| 温州市| 南安市| 新乡市| 南木林县| 寻乌县| 吉林市| 南丰县| 德清县| 桃江县| 敦化市| 金坛市| 五莲县| 南部县| 灵璧县| 台前县| 英吉沙县| 东宁县| 桃江县| 宜昌市|