fix yahoo finance

Get the Yahoo data in Python

18:42:54, June 11, 2018

Reading count: 71

I learned machine learning in Python. I found a practical tutorial online. I needed to get stock data from Yahoo. The problems and solutions are given below.
Programming environment: Linux Ubuntu16, python3.6, anaconda 1.6.14, conda 4.5.4, pandas 0.23
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Problem 1: An environment interpretation error occurred while downloading Pandas _datareader
Because the Yahoo data needs to be retrieved through the Pandas _datareader module, you need to download and install the package
Environment parse error occurs with Conda Install Pandas _datareader (conda installation is used because anaconda is used to build the Python compile and edit environment) :

[email protected]:~$ conda install pandas_datareader
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - pandas_datareader

Current channels:

  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/free/linux-64
  - https://repo.anaconda.com/pkgs/free/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/pro/linux-64
  - https://repo.anaconda.com/pkgs/pro/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Solution 1: Then change to PIP Install safari _datareader to install successfully!
Solution two: Later, I found that when I was using Conda to install the module, there were jupyter Notebook still running, so I tried to close it and then used Conda install Rebuild _datareader to find it could be successfully installed.
 
Question 2: ImportError: Cannot import name ‘is_list_like’ when using import pandas_datareader as PDR
I found many methods on the Internet, including the case column on StackFlow, but I still couldn’t find one suitable for me.
Solution one: Then give up searching for a solution online and start groping instead. Because the error message is that the module named ‘is_list_like’ cannot be imported, the code to find the error is in the first line from pandas.core.common.data import is_list_like in the fred.py module. Because the common folder and the modules under that folder cannot be found in the environment, the path to import is_list_like is wrong.
Then, Baidu search: panda IS_list_like finds the official API document of Pandas, and click Source to enter the source code module. It turns out that IS_list_like exists as a method of in the following path

Finally, I get rid of the Fred. Py the first line of the import path into: from pandas. Core. Dtype. Inference import is_list_like, import pandas_datareader modules again success!
 
Question 3: run the following code, appear ImmediateDeprecationError, namely the Yahoo! Finance no longer exists because in 2017 Yahoo! It was bought by Verizon

Yahoo Daily has been immediately deprecated due to large breaks in the API without the  
introduction of a stable replacement

The code is as follows:

     

    import pandas as pd

     

    import datetime

     

    import pandas_datareader.data as web

     

    start = datetime.datetime(
    2010,1,1)

     

    end = datetime.datetime(
    2017,1,1)

     

    df = web.get_data_yahoo(
    ‘SPY’,’yahoo’,start, end)

Baidu has found one solution in the CSDN blog: install Fix_yahoo_finance (PIP Install) and then run the following code before retrieving the data.

     

    import fix_yahoo_finance as fy

     

    fy.pdr_override()

Reproduced in: https://www.cnblogs.com/ziheIT/p/9249676.html


Read More: