我正在读取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