Skip to content

Instantly share code, notes, and snippets.

@mwestwood
Created May 12, 2023 12:30
Show Gist options
  • Save mwestwood/ef403f1119cb01f93bec3b45f9d78f83 to your computer and use it in GitHub Desktop.
Save mwestwood/ef403f1119cb01f93bec3b45f9d78f83 to your computer and use it in GitHub Desktop.
import pandas as pd
# Create a sample DataFrame
df = pd.DataFrame({
'Column1': ['A', 'B', 'C'],
'Column2': ['X', 'Y', 'Z'],
'Column3': ['1', '2', '3']
})
# Combine the three columns delimited by |
df['Combined'] = df['Column1'].str.cat([df['Column2'], df['Column3']], sep='|')
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment