[英]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.