-1

I Have a question about how to merge dataframe using conditon.

I have two dataframe

df1

Pro fg material_df1 qty_df1
1 f01 m01 1
1 f01 m02 1
1 f01 m03 1
1 f01 m05 1
2 f01 m01 2
2 f01 m03 2

df2
fg material_df2 qty_df2
fg01 m01 1
fg01 m02 1
fg01 m03 1
fg01 m04 1

result: Merge with Condition per column PRO

result dataframe:
PRO fg material_df1 qty_df1 material_df2 qty_df2
1 f01 m01 1 m01 1
1 f01 m02 1 m02 1
1 f01 m03 1 m03 1
1 f01 NAN NAN m04 1
1 f01 m05 1 NAN NAN
2 f02 m01 2 m01 1
2 f02 m03 2 m03 1
2 f02 NAN NAN m02 1
2 f02 NAN NAN m04 1

enter image description here

2
  • 3
    It would help if you said exactly what the merge conditions were. Commented Jul 10 at 2:21
  • Where did the lines with f02 come from in the dataframes df1 and df2, they are not there?
    – inquirer
    Commented Jul 20 at 11:32

0

Browse other questions tagged or ask your own question.