【发布时间】:2020-05-25 21:59:44
【问题描述】:
我正在使用 HTML 解析器从网站中提取表格,如下所示:
电流输出:
1 Sep 2 Sep 3 Sep 4 Sep
00:00 11 47 54 10
01:00 12 49 46 22
...
23:00 15 34 22 40
预期输出:
2017-09-0 2017-09-02 2017-09-03 2017-09-04
00:00:00 11 47 54 10
01:00:00 12 49 46 22
...
23:00:00 15 34 22 40
但索引和标题都被识别为对象而不是日期和小时。那么我该如何解决呢?
下面是我正在使用的代码:
url = r'https://www.nratrafficdata.ie/c2/tfmonthreport.asp?sgid=ZvyVmXU8jBt9PJE$c7UXt6&spid=NRA_000000001508&reportdate=2017-09-01&enddate=2017-09-30&sidebar=1'
tables = pd.read_html(url, header=[1], index_col=0)
sp500_table = tables[0]
【问题讨论】:
标签: python html python-3.x pandas html-parsing