'How to append rows with concat to a pandas DataFrame using a for loop

I need to add rows to an existing Dataframe, one by one. If I use append, I got this warning:

main.py:41: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df_html_consolidate = df_html_consolidate.append(row_html_good, ignore_index=True)

I have the following for loop:

df_html_consolidate = pd.DataFrame()
for _, row_html_good in df_html_good.iterrows():
    canonical = str(row_html_good['Canonical Link Element 1'])

    if "/" in canonical and canonical != row_html_good['Address']:
        row_html_good['Address'] = canonical

    consolidate_mappings[row_html_good['Address']] = row_html_good['Address']

    df_html_consolidate = df_html_consolidate.append(row_html_good, ignore_index=True)

What is the best way to do this concat?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source