Python Pandas copy columns from one sheet to another sheet without changing any data?

Viewed 7810

I have an excel file with two sheets. I would like to copy 3 columns from the first sheet to the second sheet.

Note:

  • the copied 3 column’s label names have some duplicates with the second sheet. But I should keep the original data of the second sheet without changing them.
  • I have tried many methods. My best attempt so far is :

    df_new_sheet2 = pd.concat([df_old_sheet2, df_three_of_sheet1], axis=1, join_axes=[df_old_sheet2.index])     
    

But this is not the desired output.

If pandas can not do this, could you please suggest some other python package which could work ?

In case I'm not describing the problem clearly enough, I upload a pic which may help more or less. Thx for your answers~

jpg

UPDATE[2017.07.24]:

I Finally find my fault!

insert one column with index number and then , follow the resolution of b2002, things gonna to be well. :)

2 Answers
Related