Skip to content

Commit a1b84fc

Browse files
BUG: Datareader index name shows unicode characters
1 parent caeff17 commit a1b84fc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pandas_datareader/data.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ def _retry_read_url(url, retry_count, pause, name):
171171
# return 2 rows for the most recent business day
172172
if len(rs) > 2 and rs.index[-1] == rs.index[-2]: # pragma: no cover
173173
rs = rs[:-1]
174-
return rs
174+
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.
180+
rs.index.name = rs.index.name.encode('ascii', 'ignore').decode()
181+
182+
return rs
175183

176184
raise IOError("after %d tries, %s did not "
177185
"return a 200 for url %r" % (retry_count, name, url))

pandas_datareader/tests/test_data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ def test_dtypes(self):
125125
assert np.issubdtype(data.High.dtype, np.number)
126126
assert np.issubdtype(data.Volume.dtype, np.number)
127127

128+
def test_unicode_date(self):
129+
#GH8967
130+
data = web.get_data_google('F', start='JAN-01-10', end='JAN-27-13')
131+
self.assertEquals(data.index.name, 'Date')
132+
133+
128134
class TestYahoo(tm.TestCase):
129135
@classmethod
130136
def setUpClass(cls):

0 commit comments

Comments
 (0)