title: Use pandas.shift() within a group
body: <p>I have a dataframe with panel data, let's say it's time series for 100 different objects:</p>
  
  <pre><code>object  period  value 
  1       1       24
  1       2       67
  ...
  1       1000    56
  2       1       59
  2       2       46
  ...
  2       1000    64
  3       1       54
  ...
  100     1       451
  100     2       153
  ...
  100     1000    21
  </code></pre>
  
  <p>I want to add a new column <code>prev_value</code> that will store previous <code>value</code> for each object:</p>
  
  <pre><code>object  period  value  prev_value
  1       1       24     nan
  1       2       67     24
  ...
  1       99      445    1243
  1       1000    56     445
  2       1       59     nan
  2       2       46     59
  ...
  2       1000    64     784
  3       1       54     nan
  ...
  100     1       451    nan
  100     2       153    451
  ...
  100     1000    21     1121
  </code></pre>
  
  <p>Can I use .shift() and .groupby() somehow to do that?</p>