【发布时间】:2023-03-10 14:20:01
【问题描述】:
用 NLTK 提取词干后,得到字典:
> {'golden': 'gold', 'wonderfully': 'wonder', 'damaging': 'damag',
> 'useless': 'use', 'toys': 'toy', 'ducks': 'duck'}
所以我想替换 pd.Series 中的现有单词(其中值是列表):
0 ['want', 'buy', 'toys', 'ducks']
1 ['street']
2 ['damaging', 'toys', 'isolating', 'toys']
3 ['useless', 'clothing']
我希望输出为(替换玩具为玩具等。如字典中所示):
0 ['want', 'buy', 'toy', 'duck']
1 ['street']
2 ['damag', 'toy', 'isolating', 'toy']
3 ['use', 'clothing']
【问题讨论】:
标签: python-3.x pandas dictionary replace series