Python 维基百科页面中的表格

Python 维基百科页面中的表格,python,pandas,web-scraping,Python,Pandas,Web Scraping,我需要从这个表中获取tld tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains",header=0) name_country_top_domains=tables[5][['Name[5]']] country_name=tables[5][['Entity']] i、 e.所有国家一览表: 但我得到了以下错误: KeyError: "No

我需要从这个表中获取tld

tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains",header=0)
name_country_top_domains=tables[5][['Name[5]']]
country_name=tables[5][['Entity']]
i、 e.所有国家一览表:

但我得到了以下错误:

KeyError: "None of [Index(['Name[5]'], dtype='object')] are in the [columns]"

你能告诉我我做错了什么吗?

试着用
Name[7]
代替
Name[5]

tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains",header=0)
name_country_top_domains = tables[5][['Name[7]']]
country_name=tables[5][['Entity']]

尝试使用
Name[7]
而不是
Name[5]

tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains",header=0)
name_country_top_domains = tables[5][['Name[7]']]
country_name=tables[5][['Entity']]

加载后为什么不看一下
表[5]
,看看它实际上有哪些列?加载后为什么不看一下
表[5]
,看看它实际上有哪些列?我可以问一下,在查看维基百科页面时,在哪里可以找到名称[7]?
名称[7]
是列名,因为某个链接引用了该列。如果仔细观察,您会发现在列的名称旁边有一个
[7]
。如果引用发生变化,则可能会将该列的名称更改为不同的名称,如
name[8]
我可以问您在查看wikipedia页面时,在哪里可以找到该名称[7]?
name[7]
是该列的名称,因为该列有一些链接引用。如果仔细观察,您会发现在列的名称旁边有一个
[7]
。如果引用更改,列的名称可能会更改为不同的名称,如
name[8]