Data
JavaScript
x
7
1
type id count date name
2
set A AA01 Q4 21 hello
3
set A AA01 Q4 21 hello
4
set A AA01 Q4 21 hello
5
set A AA01 Q4 21 hello
6
no B BB01 Q4 21 hey
7
Desired
JavaScript
1
7
1
type id count date name full
2
set A AA01 Q4 21 hello A AA01 Q4 21 - hello
3
set A AA01 Q4 21 hello A AA01 Q4 21 - hello
4
set A AA01 Q4 21 hello A AA01 Q4 21 - hello
5
set A AA01 Q4 21 hello A AA01 Q4 21 - hello
6
no B BB01 Q4 21 hey B BB01 Q4 21 - hey
7
Doing
JavaScript
1
2
1
df['combined']=df['full'].astype(str)+'_'+df['id']+'_'+df['count']
2
However, the other columns are not being maintained. I am still troubleshooting, any suggestion is appreciated
Advertisement
Answer
JavaScript
1
2
1
df['full'] = df.apply(lambda row: str(row['id']) + ' ' + str(row['count']) + ' ' + str(row['date']) + ' - ' + str(row['name']), axis=1)
2