<p>我有一个df(dfA),有6个国家的出生时预期寿命和每年gdp。与以下<a href="https://i.stack.imgur.com/RevK9.png" rel="nofollow noreferrer">structure</a>一起:</p>
<pre><code>country year expectancy gdp difference
chile 2000 60 1bn NA
chile 2001 63 1.5bn 0.5bn
chile 2002 65 2.5bn 0.5bn
chile 2003 68 3.5bn 1.0bn
.
.
.
chile 2015 80 10bn 10bn
</code></pre>
<p>每一行代表一个国家从2000年到2015年每年的数据(gdp、预期等),涉及6个国家</p>
<p>我创建了一个新的数据框架来存储每个国家的重要总体变量,例如每个国家的GDP增量(2015年GDP减去2000年GDP)。新的df(dfB)看起来像<a href="https://i.stack.imgur.com/q5Kp9.png" rel="nofollow noreferrer">this</a>:</p>
<pre><code>country startEndDelta (dummydata)
Chile x
China y
Germany z
Mexico a
USA b
Zimbabwe c
</code></pre>
<p>我想做的是在我的newdf中添加一个新列,显示每个国家哪一年的GDP增长最大</p>
<p>我已经能够计算这一年了,但我首先必须用一个国家的记录创建另一个数据框<a href="https://i.stack.imgur.com/ZsfhH.png" rel="nofollow noreferrer">Here I do it the way I metioned before.</a></p>
<p>我希望这样做的方式类似于:</p>
<pre><code>dfB['biggestDeltaYear'] = ?year with the biggest increase in GDP?
</code></pre>
<p>其中,这一行代码填充dfB中新列“biggestDeltaYear”的每一行</p>
<p>我有什么选择</p>
<p><strong>非常感谢</strong></p>