Python Pandas 箱線圖的實(shí)現(xiàn)
各國(guó)家用戶消費(fèi)分布
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data = {
'China': [1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2500],
'America': [1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100],
'Britain': [1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
"Russia": [800, 1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]
}
df = pd.DataFrame(data)
# df.plot.box(title="Consumer spending in each country", vert=False)
df.plot.box(title="Consumer spending in each country")
plt.grid(linestyle="--", alpha=0.3)
plt.show()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data = {
'China': [1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2500],
'America': [1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100],
'Britain': [1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],
"Russia": [800, 1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]
}
df = pd.DataFrame(data)
from pandas.plotting import table
fig, ax = plt.subplots(1, 1)
table(ax, np.round(df.describe(), 2),
loc='upper right',
colWidths=[0.1, 0.1, 0.1, 0.1]
)
# df.plot.box(title="Consumer spending in each country", vert=False)
df.plot.box(title="Consumer spending in each country",
ax=ax,
ylim=(750, 3000))
plt.grid(linestyle="--", alpha=0.3)
plt.show()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
data = {"gender": [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
'China': [1000, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2500],
'America': [1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100]
}
df = pd.DataFrame(data)
# df.boxplot(column=["China", "America"], by="gender",vert=False)
df.boxplot(column=["China", "America"], by="gender")
plt.grid(linestyle="--", alpha=0.3)
plt.show()

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python中的多進(jìn)程的創(chuàng)建與啟動(dòng)方式
這篇文章主要介紹了python中的多進(jìn)程的創(chuàng)建與啟動(dòng),python中的并發(fā)有三種形式,多進(jìn)程、多線程、協(xié)程,執(zhí)?并發(fā)任務(wù)的?的是為了提?程序運(yùn)?的效率,本文通過(guò)實(shí)例代碼詳細(xì)講解需要的朋友可以參考下2022-12-12
前女友發(fā)來(lái)加密的"520快樂(lè).pdf",我用python破解開(kāi)之后,卻發(fā)現(xiàn)
520收到前女友發(fā)來(lái)的加密PDF文件,說(shuō)打開(kāi)之后有驚喜,難道是要復(fù)合?我用python破解開(kāi)之后,卻發(fā)現(xiàn)...python干貨+劇情滿滿收藏收藏2021-08-08
python3下實(shí)現(xiàn)搜狗AI API的代碼示例
這篇文章主要介紹了python3下實(shí)現(xiàn)搜狗AI API的代碼示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-04-04
創(chuàng)建Python Docker鏡像的詳細(xì)步驟
Python和Docker是兩個(gè)極其流行的技術(shù),結(jié)合它們可以創(chuàng)建強(qiáng)大的應(yīng)用程序,Docker允許將應(yīng)用程序及其依賴項(xiàng)打包到一個(gè)獨(dú)立的容器中,而Python則提供了豐富的庫(kù)和工具來(lái)開(kāi)發(fā)應(yīng)用程序,本文將提供如何創(chuàng)建Python Docker鏡像的全面指南,,需要的朋友可以參考下2023-12-12
python將每個(gè)單詞按空格分開(kāi)并保存到文件中
這篇文章主要介紹了python將每個(gè)單詞按空格分開(kāi)并保存到文件中,需要的朋友可以參考下2018-03-03
Python Numpy教程之排序,搜索和計(jì)數(shù)詳解
這篇文章主要為大家詳細(xì)介紹了Python?NumPy中排序,搜索和計(jì)數(shù)的實(shí)現(xiàn),文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Python有一定幫助,需要的可以參考一下2022-08-08
python實(shí)現(xiàn)自動(dòng)網(wǎng)頁(yè)截圖并裁剪圖片
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)自動(dòng)網(wǎng)頁(yè)截圖并裁剪圖片,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07
python中HTMLParser模塊知識(shí)點(diǎn)總結(jié)
在本篇文章里小編給大家整理的是一篇關(guān)于python中HTMLParser模塊知識(shí)點(diǎn)內(nèi)容,有興趣的朋友們可以跟著學(xué)習(xí)下。2021-01-01

