title: Why I got NaN when computing volatility?
body: <p>I am trying to follow the equations on this paper <a href="https://www.sciencedirect.com/science/article/pii/S030142150700153X?casa_token=LH4pYGk9HHAAAAAA:ftNaTD1y7vFvFsxUxR3L9GUUVjfnnNSFWjVXp9Q9R7UdJLvaWgEDfMgqouuxa9HlnpUjgs3BKg" rel="nofollow noreferrer">here</a> , to calculate the historical volatility for power time series data.</p>
  <p>The statistical description of the data as follows :</p>
  <pre><code>count    9855.000000
  mean      291.135088
  std       187.503344
  min         0.000000
  25%       112.408512
  50%       332.370871
  75%       449.527323
  max       601.370058
  </code></pre>
  <p>Here is my implementation:</p>
  <pre><code>
  # Computing Volatility
  window_size=27
  VOLATILITY = pd.DataFrame()
  VOLATILITY['PV']= data
  #'intra-hour
  # Compute the logarithmic value  
  VOLATILITY['Log_IA'] = np.log(VOLATILITY['PV'] / VOLATILITY['PV'].shift(1))
  # Compute Volatility using the pandas rolling standard deviation function
  VOLATILITY['intra-hour'] = VOLATILITY['Log_IA'].rolling(window=window_size).std() * np.sqrt(window_size)# *100
  </code></pre>
  <p>My data have 1 year of half-hourly observations for 27 steps for each day</p>
  <p>Here is an example of the output I got for 1 selected day where the NaN problem exists</p>
  <pre><code>    
  Timestamp           PV          Log_IA     intra-hour
  2019-03-01 06:00:00 0.000000    NaN         NaN
  2019-03-01 06:30:00 2.946333    inf         NaN
  2019-03-01 07:00:00 20.963667   1.962229    NaN
  2019-03-01 07:30:00 38.284333   0.602250    NaN
  2019-03-01 08:00:00 38.224667   -0.001560   NaN
  2019-03-01 08:30:00 54.486667   0.354475    NaN
  2019-03-01 09:00:00 54.608333   0.002230    NaN
  2019-03-01 09:30:00 55.290667   0.012418    NaN
  2019-03-01 10:00:00 54.317333   -0.017761   NaN
  2019-03-01 10:30:00 54.680333   0.006661    NaN
  2019-03-01 11:00:00 42.142333   -0.260451   NaN
  2019-03-01 11:30:00 44.569000   0.055986    NaN
  2019-03-01 12:00:00 36.988333   -0.186436   NaN
  2019-03-01 12:30:00 35.802000   -0.032599   NaN
  2019-03-01 13:00:00 29.006667   -0.210478   NaN
  2019-03-01 13:30:00 43.254333   0.399572    NaN
  2019-03-01 14:00:00 45.246333   0.045024    NaN
  2019-03-01 14:30:00 29.768333   -0.418676   NaN
  2019-03-01 15:00:00 37.510667   0.231180    NaN
  2019-03-01 15:30:00 31.937000   -0.160860   NaN
  2019-03-01 16:00:00 39.990333   0.224873    NaN
  2019-03-01 16:30:00 32.263000   -0.214717   NaN
  2019-03-01 17:00:00 40.707333   0.232487    NaN
  2019-03-01 17:30:00 14.551333   -1.028726   NaN
  2019-03-01 18:00:00 10.294333   -0.346089   NaN
  2019-03-01 18:30:00 2.552667    -1.394455   NaN
  2019-03-01 19:00:00 0.036333    -4.252158   NaN
  
  </code></pre>
  <p>So, why I am getting the NaN as a result for volatility ?</p>
  <p>is it a problem with my implementation?</p>