Jun-27-2019, 01:00 PM
I have obviously never used the pandas library
Based on this answer i was astounded by the fact that pandas can just read the html with a simple single liner
Based on this answer i was astounded by the fact that pandas can just read the html with a simple single liner
df = pd.read_html(str(sov_tables))
as opposed to the OP's method:for table in sov_tables[0]: headers = [] rows = table.find_all('tr') for header in table.find('tr').find_all('th'): headers.append(header.text) for row in rows[1:]: values = [] for col in row.find_all(['th', 'td']): values.append(col.text) if values: cntr_dict = {headers[i]: values[i] for i in range(len(values))} cntr.append(cntr_dict)It appears pandas read_html method is only for tables. Is there any other tricks pandas has to someone that is not familiar with it?
Recommended Tutorials: