data2 = data.drop('Indicator Name', axis=1, inplace=True)
data3 = data2.drop('Indicator Code', axis=1, inplace=True)
x = [ data3[x].mean() for x in data.loc[:, "1960" : "2017" ]]
y = data.loc[:, "1960" : "2017" ]
plt.plot(x, y, color='orange')
plt.title('GDP Per year form 1960 to 2017')
plt.show()
我想绘制1960年至2017年所有数据的平均值,但是当我尝试获取每一列的平均值以在图表中使用它们时出现错误。实现此目标的最佳方法是什么?需要帮助
TypeError Traceback (most recent call last)
<ipython-input-63-ec5963e0529b> in <module>()
1 data2 = data.drop('Indicator Name', axis=1, inplace=True)
2 data3 = data.drop('Indicator Code', axis=1, inplace=True)
----> 3 x = [ data2[x].mean() for x in data.loc[:, "1960" : "2017" ]]
4 y = data.loc[:, "1960" : "2017" ]
5 plt.plot(x, y, color='orange')
<ipython-input-63-ec5963e0529b> in <listcomp>(.0)
1 data2 = data.drop('Indicator Name', axis=1, inplace=True)
2 data3 = data.drop('Indicator Code', axis=1, inplace=True)
----> 3 x = [ data2[x].mean() for x in data.loc[:, "1960" : "2017" ]]
4 y = data.loc[:, "1960" : "2017" ]
5 plt.plot(x, y, color='orange')
TypeError: 'NoneType' object is not subscriptable