Home Ask Login Register

Developers Planet

Your answer is one click away!

user1222 February 2016

Pandas DataFrame not working as intended

I am new to Python and I'm trying to use it for finance, specifically plotting stock prices. I am using pandas and its DataFrame object, but for some reason I cannot obtain the data I need. The web.DataReader method works, as I tried it in another program, but my code does not. Here is my code:

import numpy as np
import pandas as pd
import pandas.io.data as web

symbols = ['AAPL', 'MSFT', 'GLD']
for sym in symbols:
    data[sym] = web.DataReader(sym, data_source='yahoo', start='4/14/2014',end='01/30/2015')['Adj Close']

The output is an empty dataframe and I am not sure why, because DataReader does work as I tried it elsewhere.


Mike Müller February 2016

An update of pandas to version >=0.17.1 should solve your problem. If you use conda (recommended) :

conda update pandas 

will do.

After the update you will get a deprecation warning.

To avoid this install pandas-datareader:

conda install pandas-datareader

and change:

import pandas.io.data as web


from pandas_datareader import data as web    

Post Status

Asked in February 2016
Viewed 2,386 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life