title: How do I normalise a Pandas data column with multiple conditionals?
body: <p>I am trying to create a new pandas column which is normalised data from another column.</p>
  
  <p>I created three separate series and then merged them into one.
  While this approache has provided me with the desired result, I was wondering whether there's a better way to do this.</p>
  
  <pre><code>x = df["Data Col"].copy()
  
  #if the value is between 70 and 30 find the difference of the previous value. 
  #Positive difference = 1 &amp; Negative difference = -1
  btw = pd.Series(np.where(x.between(30, 70, inclusive=False), x.diff(), 0))
  btw[btw &lt; 0] = -1
  btw[btw &gt; 0] = 1
  
  #All values above 70 are -1
  up = pd.Series(np.where(x.gt(70), -1, 0))
  
  #All values below 30 are 1
  dw = pd.Series(np.where(x.lt(30), 1, 0))
  
  combined = up + dw + btw
  df["Normalised Col"] = np.array(combined)
  </code></pre>
  
  <p>I tried to use functions and loops directly on the Pandas Data Column but I couldn't figure out how to get the .diff()</p>