From b5ebbcd34f1e28b51d2a41b4e6693a386988423e Mon Sep 17 00:00:00 2001 From: David Stephens Date: Wed, 5 Nov 2014 20:38:02 -0800 Subject: [PATCH] BUG: Allow non-float values in get_yahoo_quotes. Fixes issue: #5229 --- doc/source/whatsnew/v0.15.1.txt | 3 ++- pandas/io/data.py | 2 +- pandas/io/tests/test_data.py | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.15.1.txt b/doc/source/whatsnew/v0.15.1.txt index aeef6d6b1c1f1..be1790103bb35 100644 --- a/doc/source/whatsnew/v0.15.1.txt +++ b/doc/source/whatsnew/v0.15.1.txt @@ -301,4 +301,5 @@ Bug Fixes - Bug in Setting by indexer to a scalar value with a mixed-dtype `Panel4d` was failing (:issue:`8702`) -- 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`) \ No newline at end of file +- 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`) +- Bug in ``get_quote_yahoo`` that wouldn't allow non-float return values (:issue:`5229`). \ No newline at end of file diff --git a/pandas/io/data.py b/pandas/io/data.py index 490d8998a3148..982755a854e36 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -143,7 +143,7 @@ def get_quote_yahoo(symbols): try: v = float(field) except ValueError: - v = np.nan + v = field data[header[i]].append(v) idx = data.pop('symbol') diff --git a/pandas/io/tests/test_data.py b/pandas/io/tests/test_data.py index 0047bc855e446..dbc439e6c872e 100644 --- a/pandas/io/tests/test_data.py +++ b/pandas/io/tests/test_data.py @@ -10,7 +10,7 @@ import pandas as pd from pandas import DataFrame, Timestamp from pandas.io import data as web -from pandas.io.data import DataReader, SymbolWarning, RemoteDataError +from pandas.io.data import DataReader, SymbolWarning, RemoteDataError, _yahoo_codes from pandas.util.testing import (assert_series_equal, assert_produces_warning, network, assert_frame_equal) import pandas.util.testing as tm @@ -151,6 +151,12 @@ def test_get_quote_series(self): def test_get_quote_string(self): df = web.get_quote_yahoo('GOOG') + @network + def test_get_quote_string(self): + _yahoo_codes.update({'MarketCap': 'j1'}) + df = web.get_quote_yahoo('GOOG') + self.assertFalse(pd.isnull(df['MarketCap'][0])) + @network def test_get_quote_stringlist(self): df = web.get_quote_yahoo(['GOOG', 'AAPL', 'GOOG'])