Menu Close

How to do string concatenation of two Python Pandas columns

To do string concatenation of two Python Pandas columns, we concatenate the columns directly.

For instance, we write

df['bar'] = df.bar.map(str) + " is " + df.foo

to update the bar column with the bar column values converted to strings with map.

And then we concatenate the ' is ' string and the foo column values onto the df.bar values.

Posted in Python, Python Answers