I want to concatenate multiple columns of Excel into single column using Python. Please find below the format:
and after concatenate it will make single column:
How can I do this?
I want to concatenate multiple columns of Excel into single column using Python. Please find below the format:
and after concatenate it will make single column:
How can I do this?
apply
functionimport pandas as pd
output = pd.read_csv('../filename.csv')
cols = output.columns
df_new = output[cols].apply(lambda row: ' '.join(row.values.astype(str)), axis=1)
df_new.to_csv('../filename_new.csv', sep='\t')