I have two pandas DataFrames of coordinates: df1 and df2. I would like to create a long DataFrame of the pairs of coordinates from each DataFrame. For example, given
import pandas as pd
df1 = pd.DataFrame({'a_x':[1,2,3],'b_y':[4,5,6]})
df2 = pd.DataFrame({'c_x':[0.1,0.2],'d_y':[0.4,0.5]})
I would like my output to look like the result of:
df_I_want = pd.DataFrame({
'a_x':[1,1,2,2,3,3],'b_y':[4,4,5,5,6,6],
'c_x':[0.1,0.2,0.1,0.2,0.1,0.2],'d_y':[0.4,0.5,0.4,0.5,0.4,0.5]
})
I can do this with loops. How can I do this as a vector operation or Pandas methods to do this type of merging/melting? Trying the Pandas merge, join, stack, etc., I'm stuck with a union of the DataFrames.