Python Forum
Moving Rows From Different Data Frames
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving Rows From Different Data Frames
#1
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_Frame
I 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.
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Better python library to create ER Diagram by using pandas data frames as tables klllmmm 0 988 Oct-19-2023, 01:01 PM
Last Post: klllmmm
  how do you style data frame that has empty rows. gsaray101 0 498 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  Is there a more elegant way to concatenate data frames? db042190 3 869 Jun-13-2023, 05:08 PM
Last Post: snippsat
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,170 Dec-19-2022, 11:11 PM
Last Post: Stockers
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,800 Dec-12-2022, 08:22 PM
Last Post: jh67
  Moving data from one Excel to another and finding maximum profit azizrasul 7 1,411 Oct-06-2022, 06:13 PM
Last Post: azizrasul
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 1,407 Jul-31-2022, 08:20 PM
Last Post: paulyan
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,601 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  How to map two data frames based on multiple condition SriRajesh 0 1,448 Oct-27-2021, 02:43 PM
Last Post: SriRajesh
  Iterating Through Data Frame Rows JoeDainton123 2 2,862 Aug-09-2021, 07:01 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020