Ted pottel
Ted pottel

Reputation: 6983

"import pandas.io.data as web " gives me a error saying no module name for pandas.io.data

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

  1. I installed stockstats by pip install stockstats

  2. imported pandas import pandas

  3. tried to import data import pandas.io.data got a error saying module pandas.io.data does not exist

Upvotes: 4

Views: 22178

Answers (2)

user8234870
user8234870

Reputation:

The sub-package pandas.io.data was deprecated in v.0.17 and removed in v.0.19. Instead there has been created a separately installable pandas-datareader package. This will allow the data modules to be independently updated on your pandas installation.

Installing

To install required packages through pip :

pip install pandas-datareader
OR
pip install git+https://github.com/pydata/pandas-datareader.git

Testing

from pandas_datareader import data
df=data.DataReader('AAPL','yahoo','2016/1/1','2017/1/1')
df.head()

yaahhoo

Resources

Upvotes: 0

Matt Messersmith
Matt Messersmith

Reputation: 13747

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``.

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.

Or you can just pip install pandas-datareader.

After that, from pandas_datareader import data works as expected:

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
>>>

Upvotes: 8

Related Questions