<p>尝试(并按<code>Country</code>分组):</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
df["Country"]=np.where(df["Country"].eq("Mainland China"), "Mainland China", "Other")
</code></pre>
<p><strong>编辑</strong></p>
<p><code>timeit</code>(请注意,我没有像<code>.loc[]</code>那样做<code>lambda doesn't support assignment</code>-请随意建议添加它的方法):</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import numpy as np
import timeit
from timeit import Timer
#proportion-wise that's the dataframe, as per OP's question
df=pd.DataFrame({"Country": ["Mainland China"]*398+["a", "b","c"]*124})
df["otherCol"]=2
df["otherCol2"]=3
#shuffle
df2=df.copy().sample(frac=1)
df3=df2.copy()
df4=df3.copy()
op2=Timer(lambda: np.where(df2["Country"].eq("Mainland China"), "Mainland China", "Other"))
op3=Timer(lambda: df3.Country.map(lambda x: x if x == 'Mainland China' else 'Others'))
op4=Timer(lambda: df4["Country"].apply(lambda x: x if x == "Mainland China" else "Others"))
print(op2.timeit(number=1000))
print(op3.timeit(number=1000))
print(op4.timeit(number=1000))
</code></pre>
<p>返回:</p>
<pre class="lang-py prettyprint-override"><code>2.1856687490362674 #numpy
2.2388894270407036 #map
2.4437739049317315 #apply
</code></pre>