still_learning
still_learning

Reputation: 806

Tables from Wikipedia page

I would need to get the tld from this table

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. the table of all countries:

But I get the following error:

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

Could you please tell me what I am doing wrong?

Upvotes: 0

Views: 143

Answers (1)

davidacmoreira
davidacmoreira

Reputation: 73

Try using Name[7] instead of 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']]

Upvotes: 2

Related Questions