pandas two dataframe cross join [duplicate]
Create a common 'key' to cross join the two:
df1['key'] = 0
df2['key'] = 0
df1.merge(df2, on='key', how='outer')
For the cross product, see this question.
Essentially, you have to do a normal merge but give every row the same key to join on, so that every row is joined to each other across the frames.
You can then add a column to the new frame by applying your function:
new_df = pd.merge(df1, df2, on=key)
new_df.new_col = new_df.apply(lambda row: myfunc(row['A_x'], row['A_y']), axis=1)
axis=1
forces .apply
to work across the rows. 'A_x' and 'A_y' will be the default column names in the resulting frame if the merged frames share a column like in your example above.