0

I have two DFs that I am trying to merge on the column 'conId'.The DFs have different number of rows and the only other overlapping column is 'delta'.DFa

DFb

I am using pf.merge(greek,on='conId',how='left')

The resulting DF is giving me columns 'delta_x' and 'delta_y'

DF Result

how can I merge these two columns into one column? Thank you!

imdevskp
  • 2,103
  • 2
  • 9
  • 23
Joan Arau
  • 151
  • 4
  • 14

1 Answers1

1

You can use

df['delta_x'] = df['detlt_x'].fillna(df['delta_y'])

then drop column if you want

df.drop(['delta_y'], axis=1)
imdevskp
  • 2,103
  • 2
  • 9
  • 23
  • Thank you! I went with pf = pf.merge(greek,on='conId',how='left') pf['delta']=pf['delta_x'].combine_first(pf['delta_y']) pf=pf.drop(['delta_x','delta_y'], axis=1) – Joan Arau Apr 22 '21 at 10:39