PyCharm(1.5.4)和熊猫0.6.0

我在MacOS 10.6.4上使用PyCharm(1.5.4)作为我的python IDE。 我正在修改一些代码来操纵股票价格数据。 作为其中的一部分,我想通过使用Pandas 0.6.0附带的DataReader函数从雅虎导入价格数据。 代码如下:

http://www.statalgo.com/2011/09/08/pandas-getting-financial-data-from-yahoo-fred-etc/

from pandas import ols, DataFrame
from pandas.stats.moments import rolling_std
from pandas.io.data import DataReader
import datetime

sp500 = DataReader("^GSPC", "yahoo", start=datetime.datetime(1990, 1, 1))
sp500_returns = sp500["adj clos"].shift(-250)/sp500["adj clos"] - 1

gdp = DataReader("GDP", "fred", start=datetime.datetime(1990, 1, 1))["value"]
gdp_returns = (gdp/gdp.shift(1) - 1)
gdp_std = rolling_std(gdp_returns, 10)
gdp_standard = gdp_returns / gdp_std

gdp_on_sp = ols(y=sp500_returns, x=DataFrame({"gdp": gdp_standard}))

sp500.plot()
gdp.plot()

当我运行代码时,出现以下错误:

Traceback (most recent call last):
  File "/Users/MyName/PycharmProjects/test/mytest", line 3, in <module>
    from pandas.io.data import DataReader
ImportError: No module named data

我看到PyCharm不知道如何解析参考“数据”。

我的Python路径设置如下:

import sys
from pprint import pprint as pp
pp(sys.path)

['/private/var/folders/st/stQUFIfOG28bmpY9dCspTk+++TI/-Tmp-',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/scikits.statsmodels-0.3.1-py2.7.egg',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python27.zip',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-darwin',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-mac',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-tk',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-old',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-dynload',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/PIL']

令人费解的是,PyCharm可以解析pandas.stats.moments,但无法解析pandas.io.data。 我检查了两个目录都有__init__.py文件(文件都是空白的)。

在这一点上,我不知道如何前进。 非常感谢帮助。

更新:

$ cat __egginst__.txt 
# egginst metadata
egg_name = 'pandas-0.3.0-3.egg'
prefix = '/Library/Frameworks/EPD64.framework/Versions/7.1'
installed_size = 1454562
rel_files = [
'EGG-INFO/pandas/__egginst__.txt',
'lib/python2.7/site-packages/pandas-0.3.0-3.egg-info',

似乎删除PyCharm的python解释器配置和重新配置解决了这个问题。 奇怪......但修正了

链接地址: http://www.djcxy.com/p/56475.html

上一篇: PyCharm (1.5.4) and Pandas 0.6.0

下一篇: load SQL in Oracle, using oracle views?