Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

Python Pandas - วาด Bar Plot แสดง Standard Deviation ด้วย Seaborn

บทนำ

Bar Plot แสดง Standard Deviation ด้วยพารามิเตอร์ ci="sd" ใน barplot() ใช้ข้อมูล Cricketers2.csv

ขั้นตอน

  1. นำเข้าไลบรารี
  2. โหลด CSV
  3. วาด Bar Plot:
    sb.barplot(x="Academy", y="Matches", data=dataFrame, ci="sd")

โค้ดเต็ม

import seaborn as sb
import pandas as pd
import matplotlib.pyplot as plt

dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers2.csv")
sb.set_theme(style="darkgrid")

sb.barplot(x="Academy", y="Matches", data=dataFrame, ci="sd")
plt.show()

ผลลัพธ์

ได้ Bar Plot แสดงจำนวนแมตช์เฉลี่ยแยกตาม Academy พร้อม Error Bars แสดง Standard Deviation