I am looking for fastest way to join columns with same names using separator. my dataframes:
df1: A,B,C,D my,he,she,it df2: A,B,C,D dog,cat,elephant,fish expected output:
df: A,B,C,D my:dog,he:cat,she:elephant,it:fish As you can see, I want to merge columns with same names, two cells in one. I can use this code for A column:
df=df1.merge(df2) df['A'] = df[['A_x','A_y']].apply(lambda x: ':'.join(x), axis = 1) In my real dataset i have above 30 columns, and i dont want to write same lines for each of them, is there any faster way to receive my expected output?