我在上一门在线课程。在练习中,我要绘制两个直方图,比较下雨和不下雨的乘客人数,这是我在在线课程中使用的代码。在
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软件运行完全相同的代码时。它显示了一个错误:
^{pr2}$为什么?在
快速解答:您可以通过将
pandas
更新到最新版本来解决此问题:在版本
0.15.0
中,kind='hist'
选项被添加到Series.plot()
中。您的代码示例应该适用于最新版本0.15.2
有关更多信息,请参见github上的release notes of 0.15.0和{a2}的增强部分。在
相关问题 更多 >
编程相关推荐