擅长:python、mysql、java
<p>通常,<a href="https://pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.Series.str.replace.html" rel="nofollow noreferrer">^{<cd1>}</a>在regex模式下操作。你有两个简单的选择。<a href="https://stackoverflow.com/questions/51335009/how-to-replace-string-replace-ending-with-a-period#comment89645218_51335009">@101</a>建议的首选方法是关闭regex:</p>
<pre><code>df['Purpose'] = df['Purpose'].str.replace('rs.', '', regex=False)
</code></pre>
<p>另一种方法是转义圆点,以便它匹配实际句点而不是任何字符。当引入<code>regex</code>参数时,在0.23.0之前的pandas版本中使用此选项:</p>
^{pr2}$
<p>Regex匹配通常比简单的字符串比较慢,因此第一个选项可以被重定向,这样性能会更好。在</p>