Search code examples
pythondataframerowpastecut

Cut a row from a dataframe and paste it to another dataframe


enter image description here

Hello , i got a DataFrame table let's call it RC1.It's at the top. enter image description here

And i got an another table let's call it Vehicle1.I need to cut RC1 row(0) to the begining of Vehicle1 table.I write my code. zero_row=rc1.iloc[0,:]

vehicle1=pd.concat([zero_row, vehicle1]).reset_index(drop=True)

Here is the result, it takes the zero_row as a column.I try to reshape it but failed. I look all stackoverflow but the examples are all lists. Thanks for everyone. enter image description here


Solution

  • In the end,no one answered so I found a solution.Here it is:

    zero_row=rc1[rc1["CUST_NO."]==0]      
    vehicle1=rc1[rc1["CAR_TYPE"]==0]
    vehicle1=pd.concat([zero_row, vehicle1]).reset_index(drop=True)
    

    This time I chose the row.Then concat, it worked!! Thanks for everyone.enter image description here