title: Generate a Dataframe that follow a mathematical function for each column / row
body: <p>Is there a way to create/generate a Pandas DataFrame from scratch, such that each record follows a specific mathematical function?</p>
  
  <p>Background: In Financial Mathematics, very basic financial-derivatives (e.g. calls and puts) have closed-form pricing formulas (e.g. Black Scholes). These pricing formulas can be called stochastic functions (because they involve a random term)</p>
  
  <p>I'm trying to create a Monte Carlo simulation of a stock price (and subseuqently an option payoff and price based on the stock price). I need, say, 1000 paths (rows) and 100 time-steps (columns). I want to "initiate" a dataframe that is 1000 by 100 and follows a stochastic equation.</p>
  
  <pre><code># Psuedo-code
  MonteCarloDF = DataFrame(rows=1000, columns=100, customFunc=TRUE,
          appliedBy='by column', 
          FUNC={s0=321; 
                s_i=prev*exp(r-q*sqrt(sigma))*T + 
                   (etc)*NormDist(rnd())*sqr(deltaT)}
          )
  </code></pre>
  
  <p>Column 0 in every row would be 321, and each subsequent column would be figured out based on the <code>FUNC</code> above.</p>
  
  <p>This is an example of something similar done in VBA</p>
  
  <pre><code>Function MonteCarlo_Vanilla_call(S, K, r, q, vol, T, N)
  
  sum = 0
  payoff = 0
  
  For i = 1 To N
   S_T = S * Exp((r - q - 0.5 * vol ^ 2) * T + vol * Sqr(T) * Application.NormSInv(Rnd()))
   payoff = Application.Max(S_T - K, 0)
   sum = sum + payoff
  Next i
  
  MonteCarlo_Vanilla_call = Exp(-r * T) * sum / N
  
  End Function
  </code></pre>
  
  <p>Every passed in variable is a constant.
  In my case, I want each next column in the same row to be just like <code>S_T</code> in the VBA code. That's really the only like that matters. I want to apply a function like <code>S_T = S * Exp((r - q - 0.5 * vol ^ 2) * T + vol * Sqr(T) * Application.NormSInv(Rnd()))</code> . Each <code>S_T</code> is the next column in the same row. There's <code>N</code> columns making one simulation. I will have, for example, 1000 simulations.</p>
  
  <pre><code>321     | 322.125 | 323.277 | ... | column 100 value
  321     | 320.704 | 319.839 | ... | column 100 value
  321     | 321.471 | 318.456 | ... | column 100 value
  ...
  row 1000| etc     | etc     | ... | value (1000,100)
  </code></pre>