<p>我认为每个群体都需要通过<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.DataFrameGroupBy.shift.html" rel="nofollow noreferrer">^{<cd1>}</a>改变所有价值观:</p>
<pre><code>df['open_next_year'] = df.groupby('ticker')['open'].shift()
print (df)
fiscalYear ticker open open_next_year
0 2017 FINL 17.488 NaN
1 2017 AAPL 17.488 NaN
2 2016 FINL 16.488 17.488
3 2016 AAPL 16.488 17.488
4 2015 FINL 15.488 16.488
5 2015 AAPL 15.488 16.488
</code></pre>
<p>更改了唯一<code>open</code>值的示例:</p>
<pre><code>print (df)
fiscalYear ticker open
0 2017 FINL 17.4881
1 2017 AAPL 17.4882
2 2016 FINL 16.4883
3 2016 AAPL 16.4884
4 2015 FINL 15.4885
5 2015 AAPL 15.4886
df['open_next_year'] = df.groupby('ticker')['open'].shift()
print (df)
fiscalYear ticker open open_next_year
0 2017 FINL 17.4881 NaN
1 2017 AAPL 17.4882 NaN
2 2016 FINL 16.4883 17.4881
3 2016 AAPL 16.4884 17.4882
4 2015 FINL 15.4885 16.4883
5 2015 AAPL 15.4886 16.4884
</code></pre>