【发布时间】:2015-12-05 21:21:14
【问题描述】:
我有一个名为“Animals”的 DataFrame,如下所示:
Words
The Black Cat
The Red Dog
我想在每个单词前添加一个加号,使其看起来像这样:
Words
+The +Black +Cat
+The +Red +Dog
我已经尝试过使用正则表达式,但它不起作用:
df = re.sub(r'([a-z]+)', r'+\1', Animals)
【问题讨论】:
标签: python regex pandas dataframe substitution