Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError in pandas.io.data.get_data_yahoo #9971

Closed
ElDeveloper opened this issue Apr 22, 2015 · 2 comments
Closed

UnboundLocalError in pandas.io.data.get_data_yahoo #9971

ElDeveloper opened this issue Apr 22, 2015 · 2 comments
Labels
IO Data IO issues that don't fit into a more specific label

Comments

@ElDeveloper
Copy link
Contributor

In [1]: %paste
import pandas.io.data as web
all_data = {}
for ticker in ['AAPL', 'GOOG', 'IBM', 'YHOO', 'MSFT']:
    all_data[ticker] = web.get_data_yahoo(ticker, '1/1/2010', '1/1/2013')
price = pd.DataFrame({tic: data['Adj Close']
                      for tic, data in all_data.iteritems()})

## -- End pasted text --

I took the snippet above from vincent's quickstart and found that an UnboundLocalError is being raised (probably pointing to a bug).

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-1-c2d08f863001> in <module>()
      2 all_data = {}
      3 for ticker in ['AAPL', 'GOOG', 'IBM', 'YHOO', 'MSFT']:
----> 4     all_data[ticker] = web.get_data_yahoo(ticker, '1/1/2010', '1/1/2013')
      5 price = pd.DataFrame({tic: data['Adj Close']
      6                       for tic, data in all_data.iteritems()})

/Users/yoshikivazquezbaeza/.virtualenvs/ipy/lib/python2.7/site-packages/pandas/io/data.pyc in get_data_yahoo(symbols, start, end, retry_count, pause, adjust_price, ret_index, chunksize, interval)
    418         raise ValueError("Invalid interval: valid values are 'd', 'w', 'm' and 'v'")
    419     return _get_data_from(symbols, start, end, interval, retry_count, pause,
--> 420                           adjust_price, ret_index, chunksize, 'yahoo')
    421 
    422 

/Users/yoshikivazquezbaeza/.virtualenvs/ipy/lib/python2.7/site-packages/pandas/io/data.pyc in _get_data_from(symbols, start, end, interval, retry_count, pause, adjust_price, ret_index, chunksize, source)
    359     # If a single symbol, (e.g., 'GOOG')
    360     if isinstance(symbols, (compat.string_types, int)):
--> 361         hist_data = src_fn(symbols, start, end, interval, retry_count, pause)
    362     # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
    363     elif isinstance(symbols, DataFrame):

/Users/yoshikivazquezbaeza/.virtualenvs/ipy/lib/python2.7/site-packages/pandas/io/data.pyc in _get_hist_yahoo(sym, start, end, interval, retry_count, pause)
    206            '&g=%s' % interval +
    207            '&ignore=.csv')
--> 208     return _retry_read_url(url, retry_count, pause, 'Yahoo!')
    209 
    210 

/Users/yoshikivazquezbaeza/.virtualenvs/ipy/lib/python2.7/site-packages/pandas/io/data.pyc in _retry_read_url(url, retry_count, pause, name)
    175     #Get rid of unicode characters in index name.
    176     try:
--> 177         rs.index.name = rs.index.name.decode('unicode_escape').encode('ascii', 'ignore')
    178     except AttributeError:
    179         #Python 3 string has no decode method.

UnboundLocalError: local variable 'rs' referenced before assignment

My installation:

In [5]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Darwin
OS-release: 14.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

pandas: 0.16.0
nose: 1.3.4
Cython: None
numpy: 1.9.2
scipy: 0.14.0
statsmodels: None
IPython: 3.0.0
sphinx: 1.2.2
patsy: None
dateutil: 2.4.2
pytz: 2015.2
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.4.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
@jorisvandenbossche
Copy link
Member

Can you report this at https://github.com/pydata/pandas-datareader/issues? (we are moving this part of pandas over there)

@ElDeveloper
Copy link
Contributor Author

Didn't know of that repo, thanks; it seems like the problem has been solved in pydata/pandas-datareader#25, so I'm closing this issue!

@jreback jreback added the IO Data IO issues that don't fit into a more specific label label Apr 22, 2015
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Apr 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

No branches or pull requests

3 participants