title: Assignments with pd.DataFrame.loc
body: <p>I'm working on a dataframe <code>df</code>:</p>
  
  <pre><code>     0   1     2     3     4     5     6    7     
  2  418  -5   -81   526   NaN   NaN   NaN  NaN   
  5  415  -5  -116   487    -5   116   462  -24   
  7  413  -5   -81   323   NaN   NaN   NaN  NaN
  </code></pre>
  
  <p>I wrote a code to check if <code>column 4</code> is null. If true fill <code>4</code>, <code>5</code>,<code>6</code>,<code>7</code> with values of <code>0</code>, <code>1</code>, <code>2</code>, <code>3</code> and add 4 other columns with same values.</p>
  
  <pre><code>rows = df.index
  for i in rows1:
     if np.isnan(df.loc[i,4]):
         df.loc[i,4] = df.loc[i,0]
         df.loc[i,5] = df.loc[i,1]
         df.loc[i,6] = df.loc[i,2]
         df.loc[i,7] = df.loc[i,3]
         df.loc[i,8] = df.loc[i,0]
         df.loc[i,9] = df.loc[i,1]
         df.loc[i,10] = df.loc[i,2]
         df.loc[i,11] = df.loc[i,3]
  df
  </code></pre>
  
  <p>The given and desired output:</p>
  
  <pre><code>     0   1     2     3     4     5     6    7    8   9   10   11    
  2  418  -5   -81   526   418    -5   -81  526  418  -5  -81  526 
  5  415  -5  -116   487    -5   116   462  -24  NaN NaN  NaN  NaN
  7  413  -5   -81   323   413    -5   -81  323  413  -5  -81  323
  </code></pre>
  
  <p><strong>My Question:</strong> 
  How to optimize my code in order to avoid repeating assignments.
  I tried </p>
  
  <pre><code>df.loc[i,4:7]=df.loc[i,0:3]
  df.loc[i,8:11]=df.loc[i,0:3]
  </code></pre>
  
  <p>but it doesn't give the desired result.</p>