我想做一个线图,x轴是年,y轴是avo_sales.groupby(['year','type'])['type'].count()
,这意味着每年每种类型的计数,色调是类型。我做不到。它说TypeError: object of type 'int' has no len()
这些数据就是我想要绘制的
avo_sales.groupby(['year','type'])['type'].count()
Out[17]:
year type
2015 conventional 2790
organic 2807
2016 conventional 2808
organic 2808
2017 conventional 2862
organic 2860
2018 conventional 648
organic 648
Name: type, dtype: int64
这是我的密码
plt.figure()
sns.lineplot(x= avo_sales.year,y=avo_sales.groupby(['year','type'])['type'].count(),hue = avo_sales.type)
你可以尝试以下方法
以下代码适用于熊猫>;=0.25
pd.__version__
使用这些来显示版本它将给出以下输出
相关问题 更多 >
编程相关推荐