Moving Rows From Different Data Frames - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Moving Rows From Different Data Frames (/thread-28816.html) |
Moving Rows From Different Data Frames - JoeDainton123 - Aug-04-2020 Hello all I was hoping someone could help me with the following issue. I want to append a row from one data frame to another data frame. The code i have so far is as follows:- Body_Data_Frame = pandas.DataFrame(data = None, columns=['A','B','C']) #empty data frame just column headings no data Row_To_Append = pandas.DataFrame([Report.iloc[s,:]]) # i create a new data frame called Row_To_Append which contains the row from another data frame Body_Data_Frame.append(Row_To_Append) # i want to append the Row_To_Append data frame to Body_Data_FrameI dont get any errors but i cannot get any data to be appended to data fram Body_Data_Frame. I was wondering if someone could point me in the right direction? Thank you. RE: Moving Rows From Different Data Frames - scidam - Aug-06-2020 Body_Data_Frame.append(Row_To_Append) returns another data frame. So, you need to reassign the result:Body_Data_Frame = Body_Data_Frame.append(Row_To_Append)However, there is a note in official docs: Quote:Iteratively appending rows to a DataFrame can be more computationally intensive than a single concatenate. Thus, it would be more efficient to prepare a list/dictionary and concatenate it to the data frame in a single operation. |