Reputation: 557
I'm taking an online course. In the exercise I have to plot two histogram comparing rain vs no rain ridership, here is the code I used in online course.
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
It works perfect in the webpage of online course but when I installed Anaconda and use Spyder software to run the exact same code. It shows me an error:
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
Why?
Upvotes: 3
Views: 4232
Reputation: 31339
Quick answer: You can fix the problem by updating pandas
to the latest version:
conda install pandas
The kind='hist'
option was added to Series.plot()
in version 0.15.0
. Your code example should work with latest version 0.15.2
For more information, see the enhancement section of the release notes of 0.15.0 and the pull request 7809 on github.
Upvotes: 2