Skip to content

Commit cd93914

Browse files
committed
Merge pull request #8742 from dstephens99/issue5229
BUG: Allow non-float values in get_yahoo_quotes.
2 parents 04d93cf + b5ebbcd commit cd93914

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

doc/source/whatsnew/v0.15.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,5 @@ Bug Fixes
301301

302302
- Bug in Setting by indexer to a scalar value with a mixed-dtype `Panel4d` was failing (:issue:`8702`)
303303

304-
- Bug where ``DataReader``'s would fail if one of the symbols passed was invalid. Now returns data for valid symbols and np.nan for invalid (:issue:`8494`)
304+
- Bug where ``DataReader``'s would fail if one of the symbols passed was invalid. Now returns data for valid symbols and np.nan for invalid (:issue:`8494`)
305+
- Bug in ``get_quote_yahoo`` that wouldn't allow non-float return values (:issue:`5229`).

pandas/io/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_quote_yahoo(symbols):
143143
try:
144144
v = float(field)
145145
except ValueError:
146-
v = np.nan
146+
v = field
147147
data[header[i]].append(v)
148148

149149
idx = data.pop('symbol')

pandas/io/tests/test_data.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas as pd
1111
from pandas import DataFrame, Timestamp
1212
from pandas.io import data as web
13-
from pandas.io.data import DataReader, SymbolWarning, RemoteDataError
13+
from pandas.io.data import DataReader, SymbolWarning, RemoteDataError, _yahoo_codes
1414
from pandas.util.testing import (assert_series_equal, assert_produces_warning,
1515
network, assert_frame_equal)
1616
import pandas.util.testing as tm
@@ -151,6 +151,12 @@ def test_get_quote_series(self):
151151
def test_get_quote_string(self):
152152
df = web.get_quote_yahoo('GOOG')
153153

154+
@network
155+
def test_get_quote_string(self):
156+
_yahoo_codes.update({'MarketCap': 'j1'})
157+
df = web.get_quote_yahoo('GOOG')
158+
self.assertFalse(pd.isnull(df['MarketCap'][0]))
159+
154160
@network
155161
def test_get_quote_stringlist(self):
156162
df = web.get_quote_yahoo(['GOOG', 'AAPL', 'GOOG'])

0 commit comments

Comments
 (0)