VOOZH about

URL: https://www.geeksforgeeks.org/pandas/join-two-text-columns-into-a-single-column-in-pandas/

⇱ Join two text columns into a single column in Pandas - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Join two text columns into a single column in Pandas

Last Updated : 1 Jan, 2019
Let's see the different methods to join two text columns into a single column. Method #1: Using cat() function We can also use different separators during join. e.g. -, _, " " etc. Output : 👁 Image
  Method #2: Using lambda function This method generalizes to an arbitrary number of string columns by replacing df[['First', 'Last']] with any column slice of your dataframe, e.g. df.iloc[:, 0:2].apply(lambda x: ' '.join(x), axis=1). Output : 👁 Image
Method #3: Using + operator We need to convert data frame elements into string before join. We can also use different separators during join, e.g. -, _, ' ' etc. Output : 👁 Image
Comment
Article Tags:
Article Tags:

Explore