本文介绍了“将pandas.io.data导入为网络"给我一个错误,说没有pandas.io.data的模块名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是学习python并尝试将其用于股票分析.使用stockstats.

Im just learning python and trying to use it for stock anlyses.using stockstats.

  1. 我通过以下方式安装了stockstats:pip install stockstats

  1. I installed stockstats bypip install stockstats

进口大熊猫进口大熊猫

imported pandasimport pandas

试图导入数据导入pandas.io.data收到错误消息,指出模块pandas.io.data不存在

tried to import dataimport pandas.io.datagot a error saying module pandas.io.data does not exist

推荐答案

我在使用Anaconda 4.4时发现了此错误:

I got this error out of the box with Anaconda 4.4:

>>> import pandas.io.data
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.6/site-packages/pandas/io/data.py", line 2, in <module>
    "The pandas.io.data module is moved to a separate package "
ImportError: The pandas.io.data module is moved to a separate package (pandas-datareader). After installing the pandas-datareader package (https://github.com/pydata/pandas-datareader), you can change the import ``from pandas.io import data, wb`` to ``from pandas_datareader import data, wb``.

错误消息非常好.建议您从https://github.com/pydata/pandas-datareader开始安装pandas-datareader.然后将导入更改为from pandas_datareader import data.

The error message is pretty nice. It recommends you go install pandas-datareader from https://github.com/pydata/pandas-datareader. Then change your import to from pandas_datareader import data.

或者您也可以pip install pandas-datareader.

此后,from pandas_datareader import data会按预期工作:

Matthews-MacBook-Pro:python matt$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pandas_datareader import data
>>>

这篇关于“将pandas.io.data导入为网络"给我一个错误,说没有pandas.io.data的模块名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 11:43