大家好,
为了替换特定列中的某个字符串,我用了以下方法并且成功了:
dataUS['sec_type'].str.strip().str.replace("LOCAL","CORP")
现在,我想用一个字符串替换多个字符串,比如用"CORP"
替换["LOCAL", "FOREIGN", "HELLO"]
。
怎样才能使它工作呢?下面的代码没有起作用。
dataUS['sec_type'].str.strip().str.replace(["LOCAL", "FOREIGN", "HELLO"], "CORP")