title: How to write this code in an optimal (pythonic) way?
body: <p>I have the following code in R and I need to write it in an optimal way in python using pandas. I wrote it but it takes a long time to run.</p>
  
  <p>1) is there someone who can confirm that this is an equivalent of R code in python</p>
  
  <p>2) how to write it in a pythonic way(optimal way)</p>
  
  <p>in R</p>
  
  <pre><code>for (i in 1:dim(df1)[1])
      df1$column1[i] &lt;- sum(df2[i,4:33])
  </code></pre>
  
  <p>in Python</p>
  
  <pre><code>for i in range(df1.shape[0]):
      df1['column1'][i] = df2.iloc[i,3:34].sum()
  </code></pre>