pandas datareader raises AttributeError: module 'pandas.io' has no attribute 'data'

后端 未结 6 895
长发绾君心
长发绾君心 2020-12-11 07:22

This is a code I am trying

import matplotlib.pyplot as plt    
import pandas as pd
ticker = \'GLD\'
begdate = \'2014-11-11\'
enddate = \'2016-11-11\'
data1 =         


        
6条回答
  •  死守一世寂寞
    2020-12-11 07:52

    pandas has removed that functionality and it is now offered as a different package (link):

    DataReader The sub-package pandas.io.data is removed in favor of a separately installable pandas-datareader package. This will allow the data modules to be independently updated to your pandas installation. The API for pandas-datareader v0.1.1 is the same as in pandas v0.16.1. (GH8961)

    You should replace the imports of the following:

    from pandas.io import data, wb
    

    With the following:

    from pandas_datareader import data, wb
    

    Install pandas_datareader with pip install pandas-datareader and replace the code with the following:

    from pandas_datareader import data
    import datetime as dt
    ticker = 'GLD'
    begdate = '2014-11-11'
    enddate = '2016-11-11'
    data1 = data.DataReader(ticker,'yahoo',dt.datetime(2014,11,11),dt.datetime(2016,11,11))
    

提交回复
热议问题