<p>我正在尝试:</p>
<p>还有几个国家的名称中有数字和/或括号。一定要把这些拿走</p>
<p>例如</p>
<p>“古巴(加勒比岛)”应该是“古巴”</p>
<p><strong>数据帧输入</p>
<pre><code> Country Energy
18 Mexico 321000000
19 Cuba (Island of Caribeas) 102000000
20 Algeria 1959000000
21 American 2252661245
22 Andorra(no mentioned) 9000000
</code></pre>
<p><strong>我想得到这个df(df out)</strong></p>
<pre><code> Country Energy
18 Mexico 321000000
19 Cuba 102000000
20 Algeria 1959000000
21 American 2252661245
22 Andorra 9000000
</code></pre>
<p><strong>我正在尝试这个</strong></p>
<pre><code>for item in df['Country']: #remove the () with the data inside
re.sub(r" ?\(\w+\)", "", item)
</code></pre>
<p>但是我的DF没有任何变化,也没有错误,所以我不知道我做错了什么。有人能帮我吗</p>