[英]Dataframe horizontal stacked bar plot
我正在閱讀 movielens 用戶數據。 我想繪制按性別分組的年齡和職業(在兩個單獨的圖中)。 但我收到此錯誤:
user_df.groupby(['gender'])['age'].unstack().plot.bar()
AttributeError: 無法訪問“SeriesGroupBy”對象的可調用屬性“unstack”,請嘗試使用“apply”方法
我希望該圖類似於http://benalexkeen.com/bar-charts-in-matplotlib/ 中的示例數據格式如下:
user_id age gender occupation zipcode
0 1 24 M technician 85711
1 2 53 F other 94043
2 3 23 M writer 32067
3 4 24 M technician 43537
4 5 33 F other 15213
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.