Search code examples
pythontwitter

Concatenating the last three columns


I have made a dataset with columns as words and the rows are the occurrence of these words in a tweet. The last three words depict the sentiment of the tweet. I want to concatenate the last three columns into one in python. I am not understanding how to proceed.

w1 w2 w3..... zzzpostive zzznegative zzzneutral
1  0  0 ..... 1         0           0
1  0  1 ..... 0         1           0

Solution

  • If you are using pandas:

    df['new_column'] = df["zzzpostive"] + df["zzznegative"] + df['zzzneutral']