DataFrame head sample: Where I need to create a new feature of the name category which will contain sarcastic category data like data from the last six columns should combine to make the new column and the values in that column should be labeled as per the column's name of the last five columns.
Use df.loc['category A' = 1, 'category'] = 'category A'
for all possible categories:
categories = ['sarcasm', 'irony', 'satire', 'understatement', 'overstatement', 'rhetorical_question']
for category in categories:
df.loc[df[category] == 1, 'category'] = category
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.