0

Given the following two DataFrames :

df1

  unicorn  size
0    blue     3
1     red     4
2    piNk     6

df2

  unicorn  size
0    blue     1
1     red     2

How can I apply the rows of both dataframes column-wise using custom functions like this (simplified):

def some_operation(a, b):
  return # some operations

Expected result:

   size A size B. result
0    3.     1.      3
1.   3.     2.      6
2    4.     1.      4
3.   4.     2.      8
4    6.     1.      6
5.   6.     2.      12
Owen
  • 1
  • 1
  • Have you tried pd.merge()? – Asetti sri harsha Aug 25 '22 at 06:02
  • @Asettisriharsha yes, i did. However, the result is not what i expected. `pd.merge()` operate element-wise. – Owen Aug 25 '22 at 06:07
  • After reading the post [Performant cartesian product (CROSS JOIN) with pandas](#https://stackoverflow.com/questions/53699012/performant-cartesian-product-cross-join-with-pandas), I think this is what exactly the answer is. – Owen Aug 25 '22 at 06:10

0 Answers0