我在stackoverflow上找不到基于字典替换值为列表中的解决方案。
字典
dct = {"LOL": ["laught out loud", "laught-out loud"],
"TLDR": ["too long didn't read", "too long; did not read"],
"application": ["app"]}
输入
input_df = pd.DataFrame([("haha too long didn't read and laught out loud :D"),
("laught-out loud so I couldnt too long; did not read"),
("what happened?")], columns=['text'])
期望的输出结果
output_df = pd.DataFrame([("haha TLDR and LOL :D"),
("LOL so I couldnt TLDR"),
("what happened?")], columns=['text'])
编辑
向字典中添加了一个额外条目,即 "application": ["app"]
当前的解决方案输出为 "what happlicationened?"
请建议一种修复方法。