Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pandas

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

like image 707
Ted pottel Avatar asked Jan 27 '23 14:01

Ted pottel


1 Answers

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
>>>
like image 186
Matt Messersmith Avatar answered Jan 31 '23 23:01

Matt Messersmith