title: Pandas Multiply Specific Columns by Value In Row
body: <p>I am attempting to multiple specific columns a value in their respective row.</p>
  
  <p>For example:</p>
  
  <pre><code>          X         Y         Z
  A 10      1         0         1        
  B 50      0         0         0      
  C 80      1         1         1
  </code></pre>
  
  <p>Would become:</p>
  
  <pre><code>              X         Y         Z
  A 10        10         0         10        
  B 50        0          0         0      
  C 80        80         80        80
  </code></pre>
  
  <p>The problem I am having is that it is timing out when I use mul(). My real dataset is very large. I tried to iterate it with loop in my real code as follows:</p>
  
  <pre><code>for i in range(1,df_final_small.shape[0]): 
      df_final_small.iloc[i].values[3:248] = df_final_small.iloc[i].values[3:248] * df_final_small.iloc[i].values[2]
  </code></pre>
  
  <p>Which when applied to the example dataframe would look like this:</p>
  
  <pre><code>for i in range(1,df_final_small.shape[0]): 
      df_final_small.iloc[i].values[1:4] = df_final_small.iloc[i].values[1:4] * df_final_small.iloc[i].values[0]
  </code></pre>
  
  <p>There must be a better way to do this, I am having problems figuring out how to only cast the multiplication to certain columns in the row rather than the entire row.</p>
  
  <p>EDIT:
  To detail further here is my df.head(5).</p>
  
  <pre><code>id  gross   150413 Welcome Email    150413 Welcome Email Repeat Cust    151001 Welcome Email    151001 Welcome Email Repeat Cust    161116 eKomi    1702 Hot Leads Email    1702 Welcome Email - All Purchases  1804 Hot Leads  ... SILVER  GOLD    PLATINUM    Acquisition Direct Mail Conversion Direct Mail  Retention Direct Mail   Retention eMail cluster x   y
  0   0033333 46.2    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 1.0 0.0 0.0 0.0 1.0 0.0 10  -0.230876   0.461990
  1   0033331 2359.0  0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 ... 0.0 1.0 0.0 0.0 0.0 1.0 0.0 9   0.231935    -0.648713
  2   0033332 117.0   0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 ... 0.0 1.0 0.0 0.0 0.0 1.0 0.0 5   -0.812921   -0.139403
  3   0033334 89.0    0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 ... 0.0 1.0 0.0 0.0 0.0 1.0 0.0 5   -0.812921   -0.139403
  4   0033335 1908.0  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 1.0 0.0 0.0 1.0 0.0 0.0 7   -0.974142   0.145032
  </code></pre>