title: Relative Strength Index in python pandas
body: <p>I am new to pandas. What is the best way to calculate the relative strength part in the RSI indicator in pandas? So far I got the following:</p>
  
  <pre><code>from pylab import *
  import pandas as pd
  import numpy as np
  
  
  
  def Datapull(Stock):
      try:
          df = (pd.io.data.DataReader(Stock,'yahoo',start='01/01/2010'))
          return df
          print 'Retrieved', Stock
          time.sleep(5)
      except Exception, e:
          print 'Main Loop', str(e)
  
  
  def RSIfun(price, n=14):
      delta = price['Close'].diff()
      #-----------
      dUp=
      dDown=
  
      RolUp=pd.rolling_mean(dUp, n)
      RolDown=pd.rolling_mean(dDown, n).abs()
  
      RS = RolUp / RolDown
      rsi= 100.0 - (100.0 / (1.0 + RS))
      return rsi
  
  Stock='AAPL'
  df=Datapull(Stock)
  RSIfun(df)
  </code></pre>
  
  <p>Am I doing it correctly so far? I am having trouble with the difference part of the equation where you separate out upward and downward calculations</p>