擅长:python、mysql、java
<p>您可以使用<code>mask</code></p>
<pre><code>mask = (df.city == old_name) & (df.dt >= startDate) & (df.dt < endDate)
new_name = 'Boston2
df.loc[:, 'proxyCity'] = df.proxyCity.mask(mask, new_name)
# Or
df.proxyCity.mask(mask, new_name, inplace=True)
</code></pre>