title: Divide Column in Pandas Dataframe by Sum of Column
body: <p>I have a dataframe where I would like to divide each row within column A by the sum of column A and make that a new column within the dataframe. </p>
  
  <pre><code>Example:
  
          Col A   New Col
          2       .22
          3       .33
          4       .44
  Total = 9       1.00
  </code></pre>
  
  <p>I tried to sum Col A and then tried to divide by 'Total' but because Total is not a column but a row, it did not work. I just get NaN for each row within the new column. </p>
  
  <pre><code>df['New Col']= (df['ColA']/df.loc['Total']) 
  </code></pre>
  
  <p>I know you can also probably integrate a sum calculation within the one line of code instead of creating a totals row as well but not sure how to do that and could not find anything online. </p>
  
  <pre><code>df['New Col']= (df['ColA']/df.sum()) 
  </code></pre>
  
  <p>Ideas?</p>