更新应该工作。尝试这个:
df1 = df1.set_index('SubscriberKey')
df1
Output:
Inst A1 A2 A3 A4
SubscriberKey
'abc' 1 0 0 0 0
'bcd' 2 0 0 0 0
'cde' 1 0 0 0 0
'def' 3 0 0 0 0
'efg' 0 0 0 0 0
df2 = df2[1:]
df2.columns = ["SubscriberKey","A1","A2","A3","A4"]
df2 = df2.set_index('SubscriberKey')
Output:
A1 A2 A3 A4
SubscriberKey
'abc' 1 0 2 0
'bcd' 0 1 1 2
'cde' 1 1 0 0然后做:
df1.update(df2)
df1这使:
Inst A1 A2 A3 A4
SubscriberKey
'abc' 1 1 0 2 0
'bcd' 2 0 1 1 2
'cde' 1 1 1 0 0
'def' 3 0 0 0 0
'efg' 0 0 0 0 0