title: Inconsistencies in applying np.gradient function
body: <p>Previously I had been calculating the gradient between a set of points by hand. I happened to see that in the numpy library there exists a np.gradient function.</p>
  
  <p>Excitedly, I tried this on my local machine and it worked as below:</p>
  
  <pre><code>dataframe['Scrubber_Gradient_20m_mean'] = np.gradient(dataframe['ScrubberLevel'].rolling(center=False,window=2).mean())
  </code></pre>
  
  <p>This returned the rolling gradient values which is exactly what I was after. However, I have now moved some of my code to an AWS deployment on a Spyder Environment with the same numpy version as my local machine, and even though the code is the same, an error is suddenly thrown:</p>
  
  <pre><code>ValueError: Shape of array too small to calculate a numerical gradient, at least (edge_order + 1) elements are required.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Tx3c7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tx3c7.png" alt="Scrub Gradient Error Message"></a></p>
  
  <p>However, what doesn't make sense to me is that when I run the code <strong>outside</strong> of a function, and just in the console - the calculation works fine. The array is not 'too small', at least not from what I can see. </p>
  
  <p><a href="https://i.stack.imgur.com/lN0qz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lN0qz.png" alt="No Error"></a></p>
  
  <p>I can't understand the reason for this. Would anyone have any reasons for this potential inconsistent behaviour?</p>
  
  <p>So far I have tried the following:</p>
  
  <ol>
  <li>Check both Python Version / Numpy versions are the same on both AWS
  Server and Local Machine</li>
  <li>Confirm both data sets are the same both inside function / outside function</li>
  <li>Check Gradient Function Inside Function / Outside Function</li>
  </ol>
  
  <p>My numpy version is: 1.15.1 on both my local machine and AWS server.</p>
  
  <p>I have attached a snapshot of dummy data so that this can hopefully be replicated. Please use the ScrubberLevel column. <a href="https://drive.google.com/open?id=1lLot_zyqPEIwQH4WEvlw3aMd1Ho4zFkk" rel="nofollow noreferrer">Link to Data</a></p>
  
  <p>This is the code I have used to run on my local machine:</p>
  
  <pre><code>df_condabri_central_T1['Scrubber_Gradient_hour_mean'] = np.gradient(df_condabri_central_T1['ScrubberLevel'].rolling(center=False,window=6).mean())
  </code></pre>
  
  <p>This is the code I have used to run on the AWS Spyder Environment within a function:</p>
  
  <pre><code>def feature_eng(dataframe):
  #There are other features but for the sake of my problem I have restricted it to this variable
  dataframe['ScrubberLevel'] = np.gradient(dataframe['ScrubberLevel'].rolling(center=False,window=2).mean())
  return dataframe
  </code></pre>
  
  <p>Now when I run this <strong>in the console</strong> in AWS Spyder, there are no issues as seen below. 
  <a href="https://i.stack.imgur.com/WSyf0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WSyf0.png" alt="Screen when running code in AWS Spyder"></a></p>
  
  <p>However, when I try and run this via my function, I get the following:
  <a href="https://i.stack.imgur.com/JdW80.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JdW80.png" alt="enter image description here"></a></p>