Skip to content
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

ValueError in io.data Options get_all_data function. Could not convert string to float. #9430

Closed
pdiffley opened this issue Feb 6, 2015 · 3 comments
Labels
Milestone

Comments

@pdiffley
Copy link

pdiffley commented Feb 6, 2015

When making the request

opt = Options('PCLN', 'yahoo')
data = opt.get_all_data()

I get the error:

ValueError Traceback (most recent call last)
in ()
1 opt = Options('PCLN', 'yahoo')
----> 2 data = opt.get_all_data()

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in get_all_data(self, call, put)
1088 expiry_dates, _ = self._get_expiry_dates_and_links()
1089
-> 1090 return self._get_data_in_date_range(dates=expiry_dates, call=call, put=put)
1091
1092 def _get_data_in_date_range(self, dates, call=True, put=True):

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in _get_data_in_date_range(self, dates, call, put)
1102 frame = getattr(self, nam)
1103 except AttributeError:
-> 1104 frame = self._get_option_data(expiry=expiry_date, name=name)
1105 data.append(frame)
1106

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in _get_option_data(self, expiry, name)
721 frames = getattr(self, frame_name)
722 except AttributeError:
--> 723 frames = self._get_option_frames_from_yahoo(expiry)
724
725 option_data = frames[name]

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in _get_option_frames_from_yahoo(self, expiry)
653 def _get_option_frames_from_yahoo(self, expiry):
654 url = self._yahoo_url_from_expiry(expiry)
--> 655 option_frames = self._option_frames_from_url(url)
656 frame_name = '_frames' + self._expiry_to_string(expiry)
657 setattr(self, frame_name, option_frames)

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in _option_frames_from_url(self, url)
682 if not hasattr(self, 'underlying_price'):
683 try:
--> 684 self.underlying_price, self.quote_time = self._get_underlying_price(url)
685 except IndexError:
686 self.underlying_price, self.quote_time = np.nan, np.nan

/usr/local/lib/python3.4/dist-packages/pandas/io/data.py in _get_underlying_price(self, url)
700 root = self._parse_url(url)
701 underlying_price = float(root.xpath('.//*[@Class="time_rtq_ticker Fz-30 Fw-b"]')[0]
--> 702 .getchildren()[0].text)
703
704 #Gets the time of the quote, note this is actually the time of the underlying price.

ValueError: could not convert string to float: '1,044.60'

It looks like commas just need to be stripped from the text before converting to a float.

@pdiffley
Copy link
Author

pdiffley commented Feb 6, 2015

I tried stripping the commas from the text before the conversion to float in line 701, but it did not fix the problem.

@jreback
Copy link
Contributor

jreback commented Feb 6, 2015

looks like similar to #9010, which is fixed in )pandas-datareader the new spinoff data library, I think in master too).

@davidastephens
Copy link
Contributor

This was fixed in #9358. It works in 0.16.0.

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.16.0, Next Major Release Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants