Histogram biểu diễn phân phối dữ liệu. Dùng hist().
Nhập thư viện:
import pandas as pd import matplotlib.pyplot as plt
Tạo DataFrame:
dataFrame = pd.DataFrame({"Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],
"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]}) Vẽ histogram:
plt.hist(dataFrame["Reg_Price"])
Ví dụ
import pandas as pd
import matplotlib.pyplot as plt
dataFrame = pd.DataFrame({"Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],
"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]})
plt.hist(dataFrame["Reg_Price"])
plt.show() Kết quả
