If you look at the documentation for pd.DataFrame.append

Append rows of other to the end of this frame, returning a new object. Columns not in this frame are added as new columns.

(emphasis mine).

Try

df_res = df_res.append(res)

Incidentally, note that pandas isn't that efficient for creating a DataFrame by successive concatenations. You might try this, instead:

all_res = []
for df in df_all:
    for i in substr:
        res = df[df['url'].str.contains(i)]
        all_res.append(res)

df_res = pd.concat(all_res)

This first creates a list of all the parts, then creates a DataFrame from all of them once at the end.

Answer from Ami Tavory on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ python-pandas-dataframe-append
Python - Pandas dataframe.append() - GeeksforGeeks
3 weeks ago - DataFrame.append() is used in Pandas to add rows from another DataFrame, Series, dictionary or list to the end of an existing DataFrame.
Discussions

python - How do I append one pandas DataFrame to another? - Stack Overflow
To new users coming to this post after getting a "Why am I getting "AttributeError: 'DataFrame' object has no attribute 'append'?": append has been removed from the API from pandas >= 2.0 in order to discourage iteratively appending DataFrames inside a loop. The idiomatic way in 2023 to append ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Don't append rows to a pandas DataFrame
Didn't even know append existed. Horrible name btw. it doesn't append, it creates a new dataframe. More on reddit.com
๐ŸŒ r/Python
25
90
August 29, 2022
python - Create a Pandas Dataframe by appending one row at a time - Stack Overflow
How do I create an empty DataFrame, then add rows, one by one? I created an empty DataFrame: df = pd.DataFrame(columns=('lib', 'qty1', 'qty2')) Then I can add a new row at the end and fill a single More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Good alternative to Pandas .append() method, now that it has been deprecated? - Stack Overflow
I use the following method a lot to append a single row to a dataframe. However, it has been deprecated. One thing I really like about it is that it allows you to append a simple dict object. For e... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ pandas โ€บ ref_df_append.asp
Pandas DataFrame append() Method
The append() method appends a DataFrame-like object at the end of the current DataFrame.
Top answer
1 of 3
100

If you look at the documentation for pd.DataFrame.append

Append rows of other to the end of this frame, returning a new object. Columns not in this frame are added as new columns.

(emphasis mine).

Try

df_res = df_res.append(res)

Incidentally, note that pandas isn't that efficient for creating a DataFrame by successive concatenations. You might try this, instead:

all_res = []
for df in df_all:
    for i in substr:
        res = df[df['url'].str.contains(i)]
        all_res.append(res)

df_res = pd.concat(all_res)

This first creates a list of all the parts, then creates a DataFrame from all of them once at the end.

2 of 3
50

Why am I getting "AttributeError: 'DataFrame' object has no attribute 'append'?

pandas >= 2.0 append has been removed, use pd.concat instead1

Starting from pandas 2.0, append has been removed from the API. It was previously deprecated in version 1.4. See the docs on Deprecations as well as this github issue that originally proposed its deprecation.

The rationale for its removal was to discourage iteratively growing DataFrames in a loop (which is what people typically use append for). This is because append makes a new copy at each stage, resulting in quadratic complexity in memory.

1. This assume you're appending one DataFrame to another. If you're appending a row to a DataFrame, the solution is slightly different - see below.


The idiomatic way to append DataFrames is to collect all your smaller DataFrames into a list, and then make one single call to pd.concat. Here's a(n oversimplified) example

df_list = []
for df in some_function_that_yields_dfs():
    df_list.append(df)

final_df = pd.concat(df_list)

Note that if you are trying to append one row at a time rather than one DataFrame at a time, the solution is even simpler.

data = []
for a, b, c from some_function_that_yields_data():
    data.append([a, b, c])

df = pd.DataFrame(data, columns=['a', 'b', 'c'])

More information in Creating an empty Pandas DataFrame, and then filling it?

๐ŸŒ
Accessibleai
accessibleai.dev โ€บ post โ€บ appendpandasdataframe
Appending Rows to a Pandas DataFrame - Matt on ML.NET
Recently, I needed to add new rows to a Pandas DataFrame. This short article walks you through how to do just that.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ pandas-docs โ€บ version โ€บ 0.23 โ€บ generated โ€บ pandas.DataFrame.append.html
pandas.DataFrame.append โ€” pandas 0.23.1 documentation
Append rows of other to the end of this frame, returning a new object. Columns not in this frame are added as new columns. ... If a list of dict/series is passed and the keys are all contained in the DataFrameโ€™s index, the order of the columns in the resulting DataFrame will be unchanged.
๐ŸŒ
w3resource
w3resource.com โ€บ pandas โ€บ dataframe โ€บ dataframe-append.php
Pandas DataFrame: append() function - w3resource
August 19, 2022 - The append() function is used to append rows of other to the end of caller, returning a new object. Columns in other that are not in the caller are added as new columns. ... If a list of dict/series is passed and the keys are all contained in ...
Find elsewhere
Top answer
1 of 5
50
Didn't even know append existed. Horrible name btw. it doesn't append, it creates a new dataframe.
2 of 5
18
Yes, this is deprecated in most recent versions, with the push to concat(). But, concat can also be costly. Many people tend to use df.append() inside of a loop (which is already problematic, but seems easy). Switching over to pd.concat() is not a one-to-one replace, as the syntax is definitely different, and is still very costly if you want to do this inside of a loop. Instead, construct a list, and append to your list inside the loop, and then generate your DataFrame or pd.concat() after you have finished the looping. DataFrame append inside of a loop, which is sadly a common theme: df1 = pd.DataFrame(columns=columns) for i in range(10): items = [x+i for x in range(len(columns))] df1 = df1.append(pd.DataFrame([items], columns=columns), ignore_index=True) print(df1) Converting the DataFrame append() to a DataFrame concat(): df1 = pd.DataFrame(columns=columns) for i in range(10): items = [x+i for x in range(len(columns))] df2 = pd.DataFrame([items], columns=columns) df1 = pd.concat([df1, df2], ignore_index=True) print(df1)` Generating the DataFrame from a list: lol = list() for i in range(10): items = [x+i for x in range(len(columns))] lol.append(items) df1 = pd.DataFrame(lol, columns=columns) print(df1)` Or using concat() outside the loop: df1 = pd.DataFrame(columns=columns) lol = list() for i in range(10): items = [x+i for x in range(len(columns))] lol.append(items)` df1 = pd.concat([df1, pd.DataFrame(lol, columns=my_column_names)], ignore_index=True) print(df1) On large amounts of data, the latter two will be much quicker. edit: grammar, typos, battling the code formatting
๐ŸŒ
KDnuggets
kdnuggets.com โ€บ 2022 โ€บ 08 โ€บ 3-ways-append-rows-pandas-dataframes.html
3 Ways to Append Rows to Pandas DataFrames - KDnuggets
To add a Series to the dataframe, we will use the append() function after the dataframe object and add the series object in the bracket.
๐ŸŒ
Medium
medium.com โ€บ @amit25173 โ€บ understanding-pandas-dataframe-append-1ebb21a36b37
Understanding pandas.DataFrame.append() | by Amit Yadav | Medium
March 6, 2025 - Letโ€™s get straight to the point โ€” append() in pandas is like adding an extra page to your notebook. It helps you add new rows to an existing DataFrame without disturbing the original structure.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ pandas
pandas: Add rows/columns to DataFrame with assign(), insert() | note.nkmk.me
August 1, 2023 - Create a DataFrame from these lists and the row names index of the original DataFrame, and concatenate it with the original DataFrame. Note that you need to transpose the two-dimensional list holding the data. Transpose 2D list in Python (swap rows and columns) df_append = pd.DataFrame(zip(*l_data), index=df.index, columns=l_label) print(df_append) # col4 col5 col6 # row1 1000 10000 100000 # row2 2000 20000 200000 # row3 3000 30000 300000 df_result = pd.concat([df, df_append], axis=1) print(df_result) # col1 col2 col3 col4 col5 col6 # row1 1 10 100 1000 10000 100000 # row2 2 20 200 2000 20000 200000 # row3 3 30 300 3000 30000 300000
๐ŸŒ
Board Infinity
boardinfinity.com โ€บ blog โ€บ pandas-append-in-python
Pandas append() in Python | Board Infinity
August 16, 2025 - To sum up, you can append a DataFrame ... to add a column to a DataFrame, use DataFrame assign() method and if you want to add rows, use DataFrame append() method....
๐ŸŒ
Apache Spark
spark.apache.org โ€บ docs โ€บ 3.5.7 โ€บ api โ€บ python โ€บ reference โ€บ pyspark.pandas โ€บ api โ€บ pyspark.pandas.DataFrame.append.html
pyspark.pandas.DataFrame.append โ€” PySpark 3.5.7 documentation
DataFrame.append(other: pyspark.pandas.frame.DataFrame, ignore_index: bool = False, verify_integrity: bool = False, sort: bool = False) โ†’ pyspark.pandas.frame.DataFrame[source]ยถ ยท Append rows of other to the end of caller, returning a new object. Columns in other that are not in the caller ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ user_guide โ€บ merging.html
Merge, join, concatenate and compare โ€” pandas 3.0.2 documentation
If you have a Series that you want to append as a single row to a DataFrame, you can convert the row into a DataFrame and use concat().
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-append-two-data-frames-with-pandas
How to Append Two Data Frames with Pandas | Saturn Cloud Blog
November 10, 2023 - Hereโ€™s an example of how to use the concat() function to append two data frames with Pandas: import pandas as pd # create the first data frame df1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) # create the second data frame df2 = ...
๐ŸŒ
Dataquest
dataquest.io โ€บ blog โ€บ append-to-dataframe-in-r
How to Append Rows to a Dataframe in R (with 7 Code ...
April 23, 2025 - We used the assignment operator <- to save the modifications applied to the current dataframe. Often, we need to append not one but multiple rows to an R dataframe. The simplest method here is again to use the rbind() function.
๐ŸŒ
Pickl
pickl.ai โ€บ home โ€บ python โ€บ understanding the basics of pandas dataframe.append()
Understanding the Basics of Pandas Dataframe.append()
August 1, 2024 - For instance, if you have a DataFrame `df1` and want to add rows from another DataFrame `df2`, you can use `df1.append(df2)`. By default, it retains the index of the original DataFrame, but you can choose to ignore the index if required.