我想让df1合并AA, AB and v
,df3["C"] = "v"
通过 AA AB AC AD AE
0 fry pan calendar cakery chock
1 a pan calendar cakery chock
2 fry pan calendar cakery chock
3 a pan calendar cakery chock
添加。
DF1
AA AB AC AD AE AF
0 fry pan calendar cakery chock fry v pan
1 a pan calendar cakery chock a v pan
2 fry pav calendar cakery chock fry v pav
3 a pan calendar cakery chock a v pab
想要df3:
('C', 'occurred at index 0')
KeyError:
df3["C"] = np.nan
df3["C"] = "v"
AAAAAH = df1['combined']=df1.apply(lambda x:'%s_%s_%s' % (x['AA'],x['C'],x['AB']),axis=1)
df3['AB']=AAAAAH
在:
woocommerce_product_query
答案 0 :(得分:0)
您可以合并不含apply
的列:
df['new'] = df['AA'] + ' v ' + df['AB']
print (df)
AA AB AC AD AE new
0 fry pan calendar cakery chock fry v pan
1 a pan calendar cakery chock a v pan
2 fry pan calendar cakery chock fry v pan
3 a pan calendar cakery chock a v pan
或者如果需要分配到AB
列:
df['AB'] = df['AA'] + ' v ' + df['AB']
print (df)
AA AB AC AD AE
0 fry fry v pan calendar cakery chock
1 a a v pan calendar cakery chock
2 fry fry v pan calendar cakery chock
3 a a v pan calendar cakery chock