【发布时间】:2015-04-02 09:14:42
【问题描述】:
我正在参加在线课程。在练习中,我必须绘制两个直方图来比较下雨和不下雨的乘客,这是我在在线课程中使用的代码。
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
为什么?
【问题讨论】: