2017-04-05 58 views

回答

1

你可以通過Seriesdict使用replace

df['msg'] = df['msg'].replace(dictionary.set_index('old_msg')['new_msg']) 
print (df) 
     msg 
0  the 
1  wi 
2  fi 
3 account 

或者:

df['msg'] = df['msg'].replace(dictionary.set_index('old_msg')['new_msg'].to_dict()) 
print (df) 
     msg 
0  the 
1  wi 
2  fi 
3 account 
+0

你是救世主:) –