Search code examples
pythonpandasdataframeyahoo-financequantitative-finance

Pandas ignores start date of a DataFrame


I am new to python and programming in general. I'm trying to import the historical data from multiple stocks. These are imported by Yahoo Finance and are expected to cover the last 20 years. For some unknown reason, Python ignores my start date and only imports data from the previous 10 years. If I import the data of the shares individually, there are no problems. Do you know what the problem might be? BTW python only uses 30% of RAM.

assets=['EXX6.DE','GLD','SC0J.DE','EEM','BRK-B','SBUX','BABA','DIS','MSFT','ABBV','MUV2.DE','NNW.F','V'] pf_data=pd.DataFrame() for a in assets: pf_data[a]=wb.DataReader(a,data_source='yahoo',start='2000-1-1') ['Adj Close'] My code in jupyter


Solution

  • This should do the trick. I would recommend in the future (to make it easier for us to help you) to add the code as copyable text as well.
    I believe that all you have left to do is to add the rest of the columns to assets.
    This problem has been solved by looking directly at the documentation of the function you send in your picture, wb.DataReader as well as reading the documentation of the function it uses (get_data_yahoo).

    import pandas_datareader as dr
    assets = ['EXX6.DE', 'GLD', 'SC0J.DE', 'EEM']
    df = dr.data.get_data_yahoo(assets, start='1/1/2000', end='5/5/2020')
    print(df)