Skip to content

BUG: Datareader index name shows unicode characters #13

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

Merged
merged 1 commit into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pandas_datareader/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ def _retry_read_url(url, retry_count, pause, name):
# return 2 rows for the most recent business day
if len(rs) > 2 and rs.index[-1] == rs.index[-2]: # pragma: no cover
rs = rs[:-1]
return rs

#Get rid of unicode characters in index name.
try:
rs.index.name = rs.index.name.decode('unicode_escape').encode('ascii', 'ignore')
except AttributeError:
#Python 3 string has no decode method.
rs.index.name = rs.index.name.encode('ascii', 'ignore').decode()

return rs

raise IOError("after %d tries, %s did not "
"return a 200 for url %r" % (retry_count, name, url))
Expand Down
6 changes: 6 additions & 0 deletions pandas_datareader/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def test_dtypes(self):
assert np.issubdtype(data.High.dtype, np.number)
assert np.issubdtype(data.Volume.dtype, np.number)

def test_unicode_date(self):
#GH8967
data = web.get_data_google('F', start='JAN-01-10', end='JAN-27-13')
self.assertEquals(data.index.name, 'Date')


class TestYahoo(tm.TestCase):
@classmethod
def setUpClass(cls):
Expand Down