I have two columns in my dataframe.
var1 var2 01 001
I would like to create a third column that joins them together:
Convert to both columns to string and then join both the columns to form the third column.
Code:
df['var1']=df['var1'].astype(str) df['var2']=df['var2'].astype(str) df['var3'] = df[['var1', 'var2']].apply(lambda x: ''.join(x), axis=1)