对pandas read_htm中不间断空格的解码

2024-04-25 22:29:32 发布

您现在位置:Python中文网/ 问答频道 /正文

pandas.read_html的默认行为似乎是将 字符转换为unicode\xa0代码:

url = 'http://www.reuters.com/finance/stocks/company-officers/IBM'
ibm = pd.read_html(url, header=0)[0]
ibm.iloc[0,0]

'Virginia\xa0Rometty'

我知道我可以使用转换器将这些转换为以下空间:

^{pr2}$

'Virginia Rometty'

这似乎是不必要的复杂的东西,一定是相当普遍。还有别的办法吗?也许是encoding选项?在


Tags: 代码comhttpurlpandasreadhtmlwww