'Line2D' 对象没有 属性 'kind'

'Line2D' object has no property 'kind'

我刚开始学习 pandas,当时我想在创建 fig, ax = plt.subplots() 对象并将该图添加到创建的坐标轴上绘制 2013 年站点平均值的条形图' 当 运行 这部分代码 'Line2D' 对象没有 属性 'kind'

时出现此错误

fig,ax = plt.subplots(1)
x= data.columns
y=data['2013'].mean()
ax.plot(x,y,kind='bar')
```````````````````````

[this is my DATASET]

                      L06_347   LS06_347    LS06_348
Time            
2009-01-01 00:00:00 0.137417    0.097500    0.016833
2009-01-01 03:00:00 0.131250    0.088833    0.016417
2009-01-01 06:00:00 0.113500    0.091250    0.016750
2009-01-01 09:00:00 0.135750    0.091500    0.016250
... ... ... ...
2013-01-01 15:00:00 1.420000    1.420000    0.096333
2013-01-01 18:00:00 1.178583    1.178583    0.083083
2013-01-01 21:00:00 0.898250    0.898250    0.077167
2013-01-02 00:00:00 0.860000    0.860000    0.075000
11697 rows × 3 columns

另一方面,我尝试使用此代码 select 所有不同年份的 4 月、5 月和 6 月的所有数据

data[(data.index.month == 4) & (data.index.month == 5) & (data.index.month == 6)]

我也试过这种方法

data.loc[(data.index.month == 4) & (data.index.month == 5) & (data.index.month == 6)]

它什么也没显示,只是显示空列。

对于你的第一个问题,你必须使用 data.plot(x, y, kind='bar'),而不是 ax.plot()

fig,ax = plt.subplots(1)
ax = data['2013'].mean().plot(kind='bar')
ax.set_xlabel('x label name')   # replace with the labels you want
ax.set_ylabel('Mean')
plt.xticks(rotation=30)
plt.show()

对于你的第二个问题 - 使用 data[data.index.month.isin([4,5,6])]