相同的代码适用于某些IDE,但不适用于其他IDE

我对以下问题感到非常困惑。我根本不了解我的计算机如何工作。


我有以下代码:


import pandas as pd 

import numpy as np

from pandas_datareader import data as wd 

import quandl 


tickers = ['MSFT','AAPL','F','GE'] 

new_data_01 = pd.DataFrame() 

for ii in tickers:

    new_data_01[ii] = wd.DataReader(ii, data_source = 'yahoo', start ='2001-1-1')['Adj Close']

new_data_01.head()

当我同时在Spyder和Anaconda笔记本电脑上运行该软件时,效果很好。但是,当我在IDLE中运行它时,情况并非如此。我不明白为什么。这是我在IDLE中运行代码时遇到的错误...


 Traceback (most recent call last):

  File "/Users/andres/Desktop/test.py", line 9, in <module>

    new_data_01[ii] = wd.DataReader(ii, data_source = 'yahoo', start ='2001-1-1')['Adj Close']

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas_datareader/data.py", line 291, in DataReader

    raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Daily'))

pandas_datareader.exceptions.ImmediateDeprecationError: 

Yahoo Daily has been immediately deprecated due to large breaks in the API without the

introduction of a stable replacement. Pull Requests to re-enable these data

connectors are welcome.


See https://github.com/pydata/pandas-datareader/issues


饮歌长啸
浏览 165回答 1
1回答

慕娘9325324

您能否在两个IDE中提供Pandas Datareader的版本?import pandas_datareader as pdprint(pd.__version__)它们可能有所不同,这可以解释您的错误。在Pandas Datareader 6.0版中已弃用Yahoo Finance 。最近恢复了部分API,并在最新的开发版本(Github存储库的master分支)中对其进行了支持。如果一个IDE的版本不是6.0,则ImmediateDeprecationError在该环境中将无法满足您的请求。我建议从两个IDE的Github存储库中下载最新版本的Pandas Datareader。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python