Pandas Append Not Working
Problem is you need assign back appended DataFrame
, because pandas DataFrame.append
NOT working inplace like pure python append
.
It seem you want append to list
, so parameter ignore_index=True
is not necessary:
Loop solution:
houseitems = []
for data in datum:
print(data.text)
print(data.get('href'))
df = {'Title': data.text, 'Url': data.get('href')}
houseitems.append(df)
Or list comprehension
solution:
houseitems = [{'Title': data.text, 'Url': data.get('href')} for data in datum]
And then create DataFrame
:
df1 = pd.DataFrame(houseitems)
Try modify line in your code
houseitems.append(df, ignore_index=True)
as
houseitems=houseitems.append(df, ignore_index=True)