Skip to content

Commit f418975

Browse files
committed
Revert MultiIndex -> Index conversion so as to maintain consistency in the behaviour of read_html
1 parent 490005a commit f418975

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/io/html.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class _HtmlFrameParser:
186186
187187
extract_links : {None, "all", "header", "body", "footer"}
188188
Table elements in the specified section(s) with <a> tags will have their
189-
href extracted.
189+
href extracted. Note that specifying "header" will result in a
190+
:class:`~pandas.MultiIndex`.
190191
191192
.. versionadded:: 1.5.0
192193
@@ -210,7 +211,8 @@ class _HtmlFrameParser:
210211
211212
extract_links : {None, "all", "header", "body", "footer"}
212213
Table elements in the specified section(s) with <a> tags will have their
213-
href extracted.
214+
href extracted. Note that specifying "header" will result in a
215+
:class:`~pandas.MultiIndex`.
214216
215217
.. versionadded:: 1.5.0
216218
@@ -1005,9 +1007,7 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, extract_links, **
10051007
for table in tables:
10061008
try:
10071009
df = _data_to_frame(data=table, **kwargs)
1008-
# Cast MultiIndex header to an Index of tuples when extracting header
1009-
# links and replace np.nan with None.
1010-
# This maintains consistency of selection (e.g. df.columns.str[1])
1010+
# Replace nan with None for null header links for consistency throughout df.
10111011
if extract_links in ("all", "header"):
10121012
idx = df.columns.values
10131013
idx[:] = np.vectorize(
@@ -1136,7 +1136,8 @@ def read_html(
11361136
11371137
extract_links : {None, "all", "header", "body", "footer"}
11381138
Table elements in the specified section(s) with <a> tags will have their
1139-
href extracted.
1139+
href extracted. Note that specifying "header" will result in a
1140+
:class:`~pandas.MultiIndex`.
11401141
11411142
.. versionadded:: 1.5.0
11421143

0 commit comments

Comments
 (0)