I'm sure this is simple but I'm quite new to Python. I have trouble how to add a list to a dataframe column or row after each iteration of the loop. I want to loop through a list of around hundred URLs with the outer for-loop and extract the data with the inner loop. Every time
With the code now I can create a dataframe that appends all lists together to one column or one row in the dataframe. But I want every iteration of the inner loop seperately in a new colum or row of the dataframe.
list_rows = []
for x in link_href_list:
urllib.request.urlopen(x)
html = urlopen(x)
bs = BeautifulSoup(html, "lxml")
table=bs.find('tbody')
rows = table.tr.next_siblings
for row in rows:
a=row.find('td').get_text().strip()
list_rows.append(a)
list_rows.to_frame()
Unfortunately the lists of the inner loop will have different lengths! maybe someone has a simple solution or a hint what I could change? Thanks!