title: Pandas: Shift down values by one row within a group
body: <p>I have a Pandas dataframe, and I want to create a new column whose values are that of another column, shifted down by one row. The last row should show NaN.</p>
  
  <p>The catch is that I want to do this by group, with the last row of each group showing NaN. NOT have the last row of a group "steal" a value from a group that happens to be adjacent in the dataframe.</p>
  
  <p>My attempted implementation is quite shamefully broken, so I'm clearly misunderstanding something fundamental.</p>
  
  <pre><code>df['B_shifted'] = df.groupby(['A'])['B'].transform(lambda x:x.values[1:])
  </code></pre>