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
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?

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ python-pandas-dataframe-append
Python - Pandas dataframe.append() - GeeksforGeeks
4 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

Appending Data to DataFrames
I don't know if you've solved an actual problem because you definitely can just append a row of data to a dataframe using df.append(data)... More on reddit.com
๐ŸŒ r/learnpython
14
1
December 24, 2021
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
I need to append a dataframe to another and I must ensure that the order of the rows stays the same
I've no evidence of this in any way. But i've never experienced any sort of mutation in the order after reading or concatenating etc. However adding the index after the append/concat seems not to catch the point, i'd do before the concat. More on reddit.com
๐ŸŒ r/learnpython
4
2
October 18, 2021
inserting a pandas dataframe into another dataframe
What do you mean by insert? If you're working row wise or column wise it can be different. Can you give an example of what you mean? What do the two frames look like now and what do you want them to look like afterwards. https://www.tablesgenerator.com/markdown_tables Might help you make example tables. More on reddit.com
๐ŸŒ r/learnpython
8
1
December 9, 2022
๐ŸŒ
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 โ€บ pandas-append-dataframe-to-another-dataframe
Joining a DataFrame to Another DataFrame Using Pandas Concat | Saturn Cloud Blog
October 25, 2023 - Here, dataframe1 is the original DataFrame, and dataframe2 is the DataFrame that we want to combine to dataframe1. The concat() function returns a new DataFrame, which we store in the variable new_dataframe.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ pandas โ€บ ref_df_append.asp
Pandas DataFrame append() Method
The append() method returns a new DataFrame object, no changes are done with the original DataFrame.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas append() usage by examples
Pandas append() Usage by Examples - Spark By {Examples}
June 17, 2025 - By using the append() method you can append one DataFrame with another by rows and columns. This method takes other (pass list for multiple dataframes), ignore_index, verify_integrity, sort as parameters, and returns a new DataFrame with the ...
๐ŸŒ
KDnuggets
kdnuggets.com โ€บ 2022 โ€บ 08 โ€บ 3-ways-append-rows-pandas-dataframes.html
3 Ways to Append Rows to Pandas DataFrames - KDnuggets
Learn a simple way to append rows in the form of arrays, dictionaries, series, and dataframes to another dataframe.
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-append-two-dataframes-in-pandas
How to append two DataFrames in Pandas?
August 22, 2023 - To append the rows of one DataFrame with the rows of another, we can use the Pandas append() function. With the help of append(), we can combine DataFrames vertically.
๐ŸŒ
Python Examples
pythonexamples.org โ€บ pandas-append-dataframe
Append DataFrame in Pandas - Python Examples
In this example, we take two dataframes, and append second dataframe to the first. import pandas as pd # Initialize a DataFrame df_1 = pd.DataFrame( [['Somu', 68, 84, 78, 96], ['Kiku', 74, 56, 88, 85], ['Ajit', 77, 73, 82, 87]], columns=['name', 'physics', 'chemistry','algebra','calculus']) # Initialize another DataFrame df_2 = pd.DataFrame( [['Amol', 72, 67, 91, 83], ['Lini', 78, 69, 87, 92]], columns=['name', 'physics', 'chemistry','algebra','calculus']) # Append DataFrames df = df_1.append(df_2, ignore_index=True) # Print DataFrames print("df_1\n------\n",df_1) print("\ndf_2\n------\n",df_2) print("\ndf\n--------\n",df)
๐ŸŒ
Rip Tutorial
riptutorial.com โ€บ append a dataframe to another dataframe
pandas Tutorial => Append a DataFrame to another DataFrame
The two DataFrames are not required to have the same set of columns. The append method does not change either of the original DataFrames. Instead, it returns a new DataFrame by appending the original two. Appending a DataFrame to another one is quite simple:
๐ŸŒ
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 = ...
๐ŸŒ
Accessibleai
accessibleai.dev โ€บ post โ€บ appendpandasdataframe
Appending Rows to a Pandas DataFrame - Matt on ML.NET
Letโ€™s look at the code I used to solve this problem and a few alternatives. The current recommended way of adding additional observations to a Pandas DataFrame is to call the concat function.
๐ŸŒ
Maplesoft
maplesoft.com โ€บ support โ€บ help โ€บ maple โ€บ view.aspx
Append a DataFrame to another DataFrame - Maple Help
DataFrame/Append append a DataFrame or DataSeries to a DataFrame Calling Sequence Parameters Description Examples Compatibility Calling Sequence Append( df1 , df2 , opts ) Parameters df1 - : a DataFrame object df2 - : a DataFrame or DataSeries object,...
๐ŸŒ
Kanaries
docs.kanaries.net โ€บ topics โ€บ Python โ€บ append-dataframe-pandas
Append DataFrame Pandas: How to Add Rows and Columns Like a Pro โ€“ Kanaries
August 17, 2023 - While merge() and join() functions are specifically designed for merging or joining DataFrames, the append() function can also achieve this if the DataFrames have the same columns: ... In this example, df2 is appended at the end of df1, effectively merging the two DataFrames.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ appending data to dataframes
r/learnpython on Reddit: Appending Data to DataFrames
December 24, 2021 -

One thing that has always made me kinda mad at Pandas is the lack of an easy method to append a row to a dataframe.

Like if I create a dataframe like this.

df = pd.DataFrame(columns=['Name', 'Age', 'Job'])

then I want to add a row, I have to do something rediculous like

df.loc[len(df)] = ["Velocibadgery", 35, "Programmer"]

instead of just

df.append([row data])

So I decided to do something about it. I first started to create my own wrapper class for pandas, and it was a pain. To build in the same amount of functionality I basically just had to expose the dataframe outside the class, which is fine, but just hurts my OOP sensibilities. I like to keep data in my class contained in my class.

So I looked into maybe inheriting from pandas instead. So I dug into the documentation and I found that you can just extend pandas instead and tack on your own methods. So I came up with the following code

@pd.api.extensions.register_dataframe_accessor("easy")
class EasyFrame:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    def append(self, data):
        if isinstance(data[0], list):
            for row in data:
                self._obj.loc[len(self._obj)] = row
        else:
            self._obj.loc[len(self._obj)] = data

It is super simple and yet does everything I want. Now I can create a dataframe and append data super easily.

df = pd.DataFrame(columns=['Name', 'Age', 'Job'])

and append data like this

df.easy.append(['Velocibadgery', 35, 'Programmer'])

It is great. I hope this helps some of you out.

Here is a Google Colab Notebook if you want to try it out

https://colab.research.google.com/drive/1sQdIPV9K9G5lqh__N0-xEAC4IFJgdtS8?usp=sharing

Edit:

Update code to allow assignment with a list of lists.

๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ how to append two pandas dataframes
How to Append Two Pandas DataFrames - Spark By {Examples}
June 4, 2025 - To append two Pandas DataFrames, you can use the append() function. There are multiple ways to append two pandas DataFrames, In this article, I will
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-append-a-dataframe-row-to-another-dataframe-in-python
5 Best Ways to Append a DataFrame Row to Another DataFrame in Python โ€“ Be on the Right Side of Change
February 19, 2024 - The goal is to append the row from df2 to df1 to update the sales record effectively. The DataFrame.append() method is a straightforward way to add a single row or multiple rows to the end of a DataFrame. It doesnโ€™t modify the original DataFrame but returns a new DataFrame instead.