0

I have a requirement in python where I have two excel sheets with similar columns like below

Workbook1:

breed|sex|animal|area|owner|

abc|M|dog|delhi|def

workbook2:

breed|sex|animal|area|owner|

abc|M|dog|delhi|efg

In this example whenever the multiple owners then it should create the

Result:

breed|sex|animal|area|owner1|owner2

abc|M|dog|delhi|efg|def
  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – Henry Yik Aug 25 '20 at 04:07

1 Answers1

1

I think merging / joining workbook 1 and 2 is a better way to get the result

result = pd.merge(workbook1,workbook2,left_on=['breed','sex','animal','area'], right_on=['breed','sex','animal','area'])

for more information : https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html

Fariliana Eri
  • 181
  • 2
  • 5