-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
fix for read_html with bs4 failing on table with header and one column #12975
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,6 +416,31 @@ def test_empty_tables(self): | |
res2 = self.read_html(StringIO(data2)) | ||
assert_framelist_equal(res1, res2) | ||
|
||
def test_header_and_one_column(self): | ||
""" | ||
Don't fail with bs4 when there is a header and only one column | ||
as described in issue #9178 | ||
""" | ||
data = StringIO('''<html> | ||
<body> | ||
<table> | ||
<thead> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't seem to replicate the error message though:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should't this raise a similar error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You forgot to add
while using patched version it works:
|
||
<tr> | ||
<th>Header</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>first</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html>''') | ||
expected = DataFrame(data={'Header': 'first'}, index=[0]) | ||
result = self.read_html(data)[0] | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_tfoot_read(self): | ||
""" | ||
Make sure that read_html reads tfoot, containing td or th. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number as a comment