Skip to content

Instantly share code, notes, and snippets.

@lisanka93
Last active July 13, 2020 15:26
Show Gist options
  • Save lisanka93/fc3b2adfcbfe01745df5f35ce4dbd4d8 to your computer and use it in GitHub Desktop.
Save lisanka93/fc3b2adfcbfe01745df5f35ce4dbd4d8 to your computer and use it in GitHub Desktop.
Merging several columns in python pandas
df['ColumnA'] = df[df.columns[1:]].apply(
lambda x: ' '.join(x.dropna().astype(str)),
axis=1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment