title: R translation to Python
body: <p>I have some code that I wrote in R that I would like to have translated into Python, but am new to python so need a bit of help</p>
  
  <p>The R code basically simulates 250 random normals, and then calculated a geometric mean return of sorts and then a max drawdown, it does this 10000 times and then combines the results, as shown below.</p>
  
  <pre><code>mu &lt;- 0.06
  sigma &lt;- 0.20
  days &lt;- 250
  n &lt;- 10000
  v &lt;- do.call(rbind,lapply(seq(n),function(y){
    rtns &lt;- rnorm(days,mu/days,sqrt(1/days)*sigma)
    p.rtns &lt;- cumprod(rtns+1)
    p.rtns.md &lt;- min((p.rtns/cummax(c(1,p.rtns))[-1])-1)
    tot.rtn &lt;- p.rtns[days]-1
    c(tot.rtn,p.rtns.md)
  }))
  </code></pre>
  
  <p>This is my attempt in Python, (if you can make it shorter/more eloquent/more efficient please suggest as answer) </p>
  
  <pre><code>import numpy as np
  import pandas as pd
  mu = float(0.06)
  sigma = float(0.2)
  days = float(250)
  n = 10000
  rtns = np.random.normal(loc=mu/days,scale=(((1/days)**0.5)*sigma),size=days)
  rtns1 = rtns+1
  prtns = rtns1.cumprod()
  totrtn = prtns[len(prtns)-1] -1
  h = prtns.tolist()
  h.insert(0,float(1))
  hdf = pd.DataFrame(prtns)/(pd.DataFrame(h).cummax()[1:len(h)]-1))[1:len(h)]]
  </code></pre>
  
  <p>and that was as far as I got... wasn't too sure if <code>hdf</code> was correct to get <code>p.rtns.md</code>, and wasnt sure how I would go about simulating this 10000 times.</p>
  
  <p>All suggestions would be greatly appreciated...</p>