【发布时间】:2017-03-12 05:05:12
【问题描述】:
我有一个 pandas 列,其中包含一些字符串值,例如:
White bear
Brown Bear
Brown Bear 100 Kg
White bear 200 cm
如何检查所有字符串是否包含序列“白熊”并将整个值(不仅是序列)替换为像“White_bear”这样的字符串?
df['Species'] = df['Species'].str.replace('White bear', 'White_bear')
不适合我,因为它只替换了序列。
【问题讨论】:
标签: python regex string pandas dataframe