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.
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).
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.
- Split a text column into two columns in Pandas DataFrame
- Create a new column in Pandas DataFrame based on the existing columns
- Apply a function to single or selected columns or rows in Pandas Dataframe
- How to fixed one column and scrollable other column or columns in Bootstrap ?
- Python | Pandas str.join() to join string/list elements with passed delimiter
- Get column index from column name of a given Pandas DataFrame
- Tableau - Split the text to columns
- How to Join Pandas DataFrames using Merge?
- Add multiple columns to dataframe in Pandas
- Difference of two columns in Pandas dataframe
- Python | Pandas DataFrame.columns
- How to rename columns in Pandas DataFrame
- Collapse multiple Columns in Pandas
- Concatenate two columns of Pandas dataframe
- Python Program to perform cross join in Pandas
- How to select multiple columns in a pandas dataframe
- How to drop one or multiple columns in Pandas Dataframe
- Getting frequency counts of a columns in Pandas DataFrame
- Iterating over rows and columns in Pandas DataFrame
- Highlight the maximum value in last two columns in Pandas - Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.