pandas.Series.str.cat() Method
The cat is the short form for concatenation. The cat() method is used for concatenating two or more strings. It takes the value of a particular column as an input along with the value of another column which has to be combined.
Syntax:
df['new_col_name'] = df['col_1_name'].str.cat(df['col_2_name'])
Parameters: It takes a parameter sep, where sep means separator, it is the special character that comes between the combined strings.
To work with Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Example:
Output:
Original DataFrame: Name Age Gender Profession Title 0 Hari 25 Male Doctor Mr 1 Mohan 36 Male Teacher Mr 2 Neeti 26 Female Singer Ms 3 Shaily 21 Female Student Ms Combined column: Name Age Gender Profession Title Full_Name 0 Hari 25 Male Doctor Mr Mr.Hari 1 Mohan 36 Male Teacher Mr Mr.Mohan 2 Neeti 26 Female Singer Ms Ms.Neeti 3 Shaily 21 Female Student Ms Ms.Shaily
need an explanation for this answer? contact us directly to get an explanation for this answer