'Line2D' object has no property 'kind'

Viewed 28955

I just started learning pandas, when I wanted to make a bar plot of the mean of the stations in year of 2013 on creating a fig, ax = plt.subplots() object and adding the plot to the created ax' I am getting this error while running this part of the code 'Line2D' object has no property '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

on the other hand I try to select all data in April, May and June for all different years with this code

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

also I have tried this way

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

it shows me nothing, just a display of empty columns.

1 Answers

For your first question, you have to use data.plot(x, y, kind='bar'), not 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()

Output

For your second question - Use data[data.index.month.isin([4,5,6])]

Related