Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Python Pandas - Vẽ bar plot dọc nhóm theo biến phân loại với Seaborn


Bar Plot hiển thị ước lượng điểm bằng cột. Dùng seaborn.barplot(). Bar plot dọc nhóm theo biến phân loại bằng cách truyền biến làm x hoặc y.

Dữ liệu: Cricketers2.csv.

Nhập thư viện:

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

Tải dữ liệu:

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

Bar plot dọc Role vs Matches:

sb.barplot(x=dataFrame["Role"], y=dataFrame["Matches"])

Ví dụ

import seaborn as sb 
import pandas as pd 
import matplotlib.pyplot as plt 
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers2.csv") 
sb.barplot(x=dataFrame["Role"], y=dataFrame["Matches"]) 
plt.show()

Kết quả

Python Pandas - Vẽ bar plot dọc nhóm theo biến phân loại với Seaborn