Advertisement
elena1234

concatenate two columns into one new column

May 21st, 2022
787
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # concatenates the string values from category_0 with category_1 into new column named 'categories',
  2. # separated by a ','
  3. df['categories'] = df['category_0'].str.cat(df['category_1'], sep = ', ')
  4. df.head()
Advertisement
RAW Paste Data Copied
Advertisement