2015-09-29 31 views
2

我想推出这个代码,我发现从IPython笔记本 (我也添加了一些代码:interactive(True)...) 而我的问题是,当我使用“run模块“与空闲它启动”data.plot“ 然后它加载并没有任何反应。 data.plot似乎不起作用。空闲和熊猫蟒

谢谢,如果你有任何想法。

注:如果没有 “互动(真)” 一箱显示了 “运行时错误”

import pandas as pd 
import matplotlib.pyplot as plt 
from matplotlib import interactive 
interactive(True) 

# read data into a DataFrame 
data = pd.read_csv('http://www-bcf.usc.edu/~gareth/ISL/Advertising.csv', index_col=0) 
print(data.head()) 

# print the shape of the DataFrame 
print data.shape 

# visualize the relationship between the features and the response using scatterplots 
fig, axs = plt.subplots(1, 3, sharey=True) 
data.plot(kind='scatter', x='TV', y='Sales', ax=axs[0], figsize=(16, 8)) 
data.plot(kind='scatter', x='Radio', y='Sales', ax=axs[1]) 
data.plot(kind='scatter', x='Newspaper', y='Sales', ax=axs[2]) 

回答

5

尝试display(data.plot(PARAMS))。要导入它,请尝试from IPython.core.display import display

这适用于我在一些iPython笔记本电脑。

+0

我有一个错误“NameError:name'显示'未定义'我应该添加哪个库? – bouritosse

+0

已在答案中添加。 – ZtoYi