导入 pandas.io.data

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47972667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 04:57:48  来源:igfitidea点击:

Importing pandas.io.data

pythonpython-3.xpandas

提问by newbiecoder_

I am following along with this tutorial: https://pythonprogramming.net/data-analysis-python-pandas-tutorial-introduction/

我正在关注本教程:https: //pythonprogramming.net/data-analysis-python-pandas-tutorial-introduction/

He suggests the following import:

他建议以下导入:

import pandas.io.data as web

so that I can implement:

以便我可以实施:

df = web.DataReader("XOM", "yahoo", start, end)

However, this is for Python 2.7 and I am using Python3. I have Googled this question and found some results, but can't make it work. Can anyone assist me?

但是,这是针对 Python 2.7 的,我使用的是 Python3。我在谷歌上搜索了这个问题并找到了一些结果,但无法使其工作。任何人都可以帮助我吗?

回答by Tai

Update:

更新:

As mentioned by wilkas, now you might need to do

正如威尔卡斯所提到的,现在你可能需要做

import pandas_datareader.data as web


I am assuming that you are using the latest version of the package. Check out the newest documentation at https://pandas-datareader.readthedocs.io/en/latest/

我假设您使用的是最新版本的软件包。在https://pandas-datareader.readthedocs.io/en/latest/查看最新文档

Let me quote the documentation:

让我引用文档:

Usage

Starting in 0.19.0, pandas no longer supports pandas.io.data or pandas.io.wb, so you must replace your imports from pandas.iowith those from pandas_datareader:

Usage

从 0.19.0 开始,pandas 不再支持 pandas.io.data 或 pandas.io.wb,因此您必须将imports from pandas.io它们替换为from pandas_datareader

from pandas.io import data, web # <- Don't use these Now.
from pandas_datareader import data, web  # <- use this.

Thus, your import statement should be

因此,您的导入语句应该是

from pandas_datareader import web

Then you can implement

然后你可以实现

f = web.DataReader("F", 'yahoo', start, end) 

See their document to use Yahoo data from HERE

这里查看他们的文档以使用雅虎数据