title: How to shift values in a data frame according the a list?
body: <p>Consider the following data frame:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import random
  
  characteristics = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
  N = int(1e5)
  random_characteristics = [random.choice(characteristics) for i in range(N)]
  
  df = pd.DataFrame(data={'character': random_characteristics})
  
  df
  
  --------------------------------------------------------------------
         character
  0          A
  1          G
  2          E
  3          G
  4          D
  ...        ...
  99995      E
  99996      G
  99997      A
  99998      D
  99999      B
  
  100000 rows × 1 columns
  --------------------------------------------------------------------
  </code></pre>
  <p>Now, my goal is to create a new column <code>characteristics_shifted</code> that is shifted according to the list <code>characteristics</code>, where the number of shifts can be specified by the user.
  For instance, if you specify <code>shift = 1</code>, then each character is shifted by one. If the character equals <code>H</code>, then it cannot be shifted by one and therefore remains the same. If <code>shift = 2</code> and the character equals <code>B</code>, then I want to get <code>D</code>. If, in turn, the character equals <code>G</code>, I want to get <code>H</code>. The same holds for negative shifts, but in the other direction.</p>
  <p>Example:</p>
  <pre class="lang-py prettyprint-override"><code>character  characteristics_shifted (shift=1)  characteristics_shifted (shift=-2)  
  
  A          B                                  A
  G          H                                  F
  E          F                                  D
  G          H                                  F
  D          E                                  C
  H          H                                  F
  H          H                                  F
  A          B                                  A
  E          F                                  D
  C          D                                  B
  F          G                                  E
  </code></pre>
  <p>Note: My data frame contains around 21 mio. rows. It does not contain nan values.</p>