title: Proper way to use iloc in Pandas
body: <p>I have the following dataframe df:</p>
  
  <pre><code>print(df)
  
      Food         Taste
  0   Apple        NaN
  1   Banana       NaN
  2   Candy        NaN
  3   Milk         NaN
  4   Bread        NaN
  5   Strawberry   NaN
  </code></pre>
  
  <p>I am trying to replace values in a range of rows using iloc:</p>
  
  <pre><code>df.Taste.iloc[0:2] = 'good'
  df.Taste.iloc[2:6] = 'bad'
  </code></pre>
  
  <p>But it returned the following SettingWithCopyWarning message:</p>
  
  <pre><code>SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
  </code></pre>
  
  <p>So, I found this <a href="https://stackoverflow.com/questions/41270569/settingwithcopywarning-pandas-setting-via-index">Stackoverflow page</a> and tried this:</p>
  
  <pre><code>df.iloc[0:2, 'Taste'] = 'good'
  df.iloc[2:6, 'Taste'] = 'bad'
  </code></pre>
  
  <p>Unfortunately, it returned the following error:</p>
  
  <pre><code>ValueError: Can only index by location with a [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array]
  </code></pre>
  
  <p>What would be the proper way to use iloc in this situation? Also, is there a way to combine these two lines above?</p>