You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pandas.io.data as web
import datetime
symbol = "AAPL"
end = datetime.datetime.now()
start = end - datetime.timedelta(days=10)
df = web.DataReader("AAPL", 'google', start, end)
df.index.name
is '\xef\xbb\xbfDate' it should be only 'Date'
\xef\xbb\xbf characters are invisible !
A quick and dirty solution is to change
def _retry_read_url(url, retry_count, pause, name):
for _ in range(retry_count):
time.sleep(pause)
# kludge to close the socket ASAP
try:
with urlopen(url) as resp:
lines = resp.read()
except _network_error_classes:
pass
else:
rs = read_csv(StringIO(bytes_to_str(lines)), index_col=0,
parse_dates=True)[::-1]
# Yahoo! Finance sometimes does this awesome thing where they
# 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
raise IOError("after %d tries, %s did not "
"return a 200 for url %r" % (retry_count, name, url))
to
def _retry_read_url(url, retry_count, pause, name):
for _ in range(retry_count):
time.sleep(pause)
# kludge to close the socket ASAP
try:
with urlopen(url) as resp:
lines = resp.read()
except _network_error_classes:
pass
else:
rs = read_csv(StringIO(bytes_to_str(lines)), index_col=0,
parse_dates=True)[::-1]
rs.index.name = 'Date'
# Yahoo! Finance sometimes does this awesome thing where they
# 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
raise IOError("after %d tries, %s did not "
"return a 200 for url %r" % (retry_count, name, url))
so adding rs.index.name = 'Date'
fix the problem but it could have side effect for other datasource
Kind regards
The text was updated successfully, but these errors were encountered:
femtotrader
changed the title
DataReader with google source return DataFrame with incorrect index name
DataReader with google source returns DataFrame with incorrect index name
Dec 2, 2014
Hello,
is
'\xef\xbb\xbfDate'
it should be only'Date'
\xef\xbb\xbf characters are invisible !
A quick and dirty solution is to change
to
so adding rs.index.name = 'Date'
fix the problem but it could have side effect for other datasource
Kind regards
The text was updated successfully, but these errors were encountered: