fix(cn_index): wrap literal HTML in StringIO for pd.read_html#2258
Open
he-yufeng wants to merge 1 commit into
Open
fix(cn_index): wrap literal HTML in StringIO for pd.read_html#2258he-yufeng wants to merge 1 commit into
he-yufeng wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#2047 wrapped the literal HTML passed to
pd.read_htmlin aStringIOfor theus_indexcollector to silence pandas'FutureWarning:The parallel
cn_indexcollector was missed._parse_tablepasses the csindex response body (an HTML string, not a URL/path) straight topd.read_html(content)atscripts/data_collector/cn_index/collector.py:185, so it still hits the same deprecation and will break once pandas drops literal-string support.Change
Import
StringIOand wrap the content, matching what #2047 did forus_index. No behavior change on supported pandas versions;StringIOhas always been accepted byread_html.Reproduced locally on pandas 2.3.3:
Note
I scoped this to the
read_htmlfix to stay a clean parallel of #2047. The same file also callsDataFrame.applymap(line 174), which pandas 2.1 deprecates in favour ofDataFrame.map, butDataFrame.maponly exists from 2.1 onward whilesetup.pystill supportspandas>=1.1, so swapping it would need version handling and is left out here.