0

I want to perform an append operation between two dataframes with a "For" loop, but this method does not work!

df1 = pd.DataFrame(
    {
        "A": ["A0", "A1", "A2", "A3"],
        "B": ["B0", "B1", "B2", "B3"],
        "C": ["C0", "C1", "C2", "C3"],
        "D": ["D0", "D1", "D2", "D3"],
    },
    index=[0, 1, 2, 3],
)

df2 = pd.DataFrame()

for i in range(len(df1)):
    df2.append(df1.iloc[i])

error:

AttributeError: 'DataFrame' object has no attribute 'append'

This method works well on lists

How can I use this method for pandas?

I want every row that was approved by me to be added to the empty list of the df2 dataframe.

0

1 Answer 1

1

Append was replaced by concat:

df2 = pd.concat([df2, df1.iloc[i]], axis=1)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.