Код: Выделить всё
`population_data = pd.DataFrame(columns=["Rank", "Country", "Population", "Area", "Density"])
for row in tables[table_index].tbody.find_all('tr'):
col = row.find_all('td')
if (col != []):
rank = col[0].text
country = col[1].text
population = col[2].text.strip()
area = col[3].text.strip()
density = col[4].text.strip()
population_data = population_data.append({"Rank":rank, "Country":country, "Population":population, "Area":area, "Density": density}, ignore_index=True)
print(population_data)`
Ожидается таблица, похожая на img. Он подсказывает AttributeError: объект DataFrame не имеет атрибута добавления. Вы имели в виду: '_append'? ошибка. В чем проблема с моим кодом?
Подробнее здесь: https://stackoverflow.com/questions/781 ... d-function