Skip to content

BUG: Allow non-float values in get_yahoo_quotes. #8742

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
Nov 7, 2014
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
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.15.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
- 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`).
2 changes: 1 addition & 1 deletion pandas/io/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 7 additions & 1 deletion pandas/io/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'])
Expand Down