Python 为什么我能';在Spyder中是否不使用matplotlib.pyplot?

Python 为什么我能';在Spyder中是否不使用matplotlib.pyplot?,python,pandas,anaconda,Python,Pandas,Anaconda,我正在上一门在线课程。在练习中,我必须绘制两个比较下雨和不下雨乘客的柱状图,以下是我在在线课程中使用的代码 import numpy as np import pandas import matplotlib.pyplot as plt def entries_histogram(turnstile_weather): plt.figure() ax = turnstile_weather['ENTRIESn_hourly'][turnstile_weather['rain'

我正在上一门在线课程。在练习中,我必须绘制两个比较下雨和不下雨乘客的柱状图,以下是我在在线课程中使用的代码

import numpy as np
import pandas
import matplotlib.pyplot as plt

def entries_histogram(turnstile_weather):

    plt.figure()
    ax = turnstile_weather['ENTRIESn_hourly'][turnstile_weather['rain'] == 0].plot(kind = 'hist', title = 'Histogram of ENTRIESn_hourly', bins = 30)
    turnstile_weather['ENTRIESn_hourly'][turnstile_weather['rain'] == 1].plot(kind = 'hist', bins = 30, ax=ax)
    ax.set_ylabel('Frequency')
    ax.set_xlabel('ENTRIESn_hourly')
    return plt
它在在线课程的网页上运行得非常完美,但当我安装Anaconda并使用Spyder软件运行完全相同的代码时。它向我显示了一个错误:

C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py in plot_series(series, label, kind, use_index, rot, xticks, yticks, xlim, ylim, ax, style, grid, legend, logx, logy, secondary_y, **kwds)
   2231         klass = _plot_klass[kind]
   2232     else:
-> 2233         raise ValueError('Invalid chart type given %s' % kind)
   2234 
   2235     """

ValueError: Invalid chart type given hist
为什么?

快速回答:您可以通过将
pandas
更新到最新版本来解决此问题:

conda install pandas
kind='hist'
选项已添加到
0.15.0版
中的
Series.plot()
。您的代码示例应使用最新版本
0.15.2


有关更多信息,请参阅的增强部分和github上的。

我仍然存在此问题。我安装了matplotlib,甚至采用了上述建议的解决方案,但它对我不起作用:导入matplotlib.pyplot作为plt回溯(最近一次调用):文件“”,第1行,导入matplotlib.pyplot作为plt ModuleNotFoundError:没有名为“matplotlib”的模块