Categories
Python Answers

How to do string concatenation of two Python Pandas columns

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *