From 0f2af13c4568333983e45a03b4cc8f8d0b013bec Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Mon, 28 Jan 2013 20:54:09 -0700 Subject: [PATCH 1/3] BUG: Small bug in helper functions _unpack and _parse_options_data --- pandas/io/data.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/io/data.py b/pandas/io/data.py index e4c1ae9a9817a..c3456b69e2da3 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -216,11 +216,12 @@ def get_data_famafrench(name, start=None, end=None): def _unpack(row, kind='td'): - return [val.text for val in row.findAll(kind)] + elts = row.findall('.//%s' % kind) + return[val.text_content() for val in elts] def _parse_options_data(table): - rows = table.findAll('tr') + rows = table.findall('.//tr') header = _unpack(rows[0], kind='th') data = [_unpack(r) for r in rows[1:]] return TextParser(data, names=header).get_chunk() From 1fc53015b13fd9a62cf607d11d6695a74965ab36 Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Mon, 28 Jan 2013 23:10:33 -0700 Subject: [PATCH 2/3] Restored the options to TextParser. They got removed on a copy/paste from my local test file and I just caught it --- pandas/io/data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/io/data.py b/pandas/io/data.py index 9acace5a97904..a59b1f29547b9 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -225,11 +225,13 @@ def _unpack(row, kind='td'): els = row.findall('.//%s' % kind) return[val.text_content() for val in els] + def _parse_options_data(table): rows = table.findall('.//tr') header = _unpack(rows[0], kind='th') data = [_unpack(r) for r in rows[1:]] - return TextParser(data, names=header).get_chunk() + # Use ',' as a thousands separator as we're pulling from the US site. + return TextParser(data, names=header, na_values=['N/A'], thousands=',').get_chunk() class Options(object): From f2e7152c670ce68c1eb93533d4fe65073638e88d Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Mon, 28 Jan 2013 23:11:35 -0700 Subject: [PATCH 3/3] Moved line to be pep8 compliant --- pandas/io/data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/data.py b/pandas/io/data.py index a59b1f29547b9..3bf177b47b9d6 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -231,7 +231,8 @@ def _parse_options_data(table): header = _unpack(rows[0], kind='th') data = [_unpack(r) for r in rows[1:]] # Use ',' as a thousands separator as we're pulling from the US site. - return TextParser(data, names=header, na_values=['N/A'], thousands=',').get_chunk() + return TextParser(data, names=header, na_values=['N/A'], + thousands=',').get_chunk() class Options(object):