I have a Pandas dataframe with two columns of text data, and I want to combine them into a single column. How can I achieve this?
Here’s an example dataframe:
import pandas as pd
df = pd.DataFrame({'A': ['Hello', 'Goodbye', 'Welcome'],
'B': ['world', 'everyone', 'back']})
I want to combine columns A and B into a new column C so that the resulting DataFrame looks like this:
A B C
0 Hello world Hello world
1 Goodbye everyone Goodbye everyone
2 Welcome back Welcome back
I’m not sure how to approach this problem. Can someone help me out and provide some code examples or guidance on how to do this? Thank you!