我嘗試使用此資料框顯示直方圖。
gr_age weighted_cost
0 1 2272.985462
1 2 2027.919360
2 3 1417.617779
3 4 946.568598
4 5 715.731002
5 6 641.716770
我想使用gr_agecolumn 作為 X 軸和weighted_costY 軸。這是我正在尋找的 Excel 示例:

我嘗試使用以下代碼,并使用discrete=True,但它給出了另一個結果,并且我在 displot 上做得并沒有更好。
sns.histplot(data=df, x="gr_age", y="weighted_cost")
plt.show()
謝謝你的想法!
uj5u.com熱心網友回復:
你想要一個barplot(x vs y values) 而不是 ahistplot來繪制資料集的分布:
import seaborn as sns
ax = sns.barplot(data=df, x='gr_age', y='weighted_cost', color='#4473C5')
ax.set_title('Values by age group')
輸出:

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/334593.html
標籤:Python 熊猫 数据框 matplotlib 海生
下一篇:Python熊貓回圈槽列
