title: How to replace row values and index label efficiently in Pandas?
body: <p>I'm looking for an efficient way to repeatedly update rows in a DataFrame. By this I mean changing row values <strong>and its index label</strong>. I specifically need help with the latter. The best I could find is <a href="https://stackoverflow.com/questions/14110721/how-to-change-pandas-dataframe-index-value">How to change Pandas dataframe index value?</a> However, this updates the entire index, while I care about a single index label.</p>
  
  <p>Directly assigning to index[n] is not supported:</p>
  
  <pre><code>&gt;&gt;&gt; df.index[1] = 'new_label'
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python2.7/dist-packages/pandas/indexes/base.py", line 1374, in __setitem__
      raise TypeError("Index does not support mutable operations")
  </code></pre>
  
  <p>Would it work to modify (assign to) the numpy array underlying the index?</p>
  
  <pre><code>&gt;&gt;&gt; df.index._values[1] = 'new_label'
  </code></pre>
  
  <p>The updates don't break index sortedness.</p>
  
  <hr>
  
  <p>More context: </p>
  
  <p>I have a DataFrame indexed by timestamps (DatetimeIndex) where I need to efficiently append new rows in real time (many times per second). I preallocate a large fixed-size DataFrame with NaT/NaN s and I append rows by writing into the next empty row.</p>