title: Pandas: Slice Dataframe by Datetime (that may not exist) and Return View
body: <p>I have a large DataFrame which I would like to slice so that I can perform some calculations on the sliced dataframe so that the values are updated in the original. In addition I am slicing the dataframe by a start and end time that may not exist in the index. Below is a simplified example, but I will actually want to update a number of columns based on different calculations.</p>
  
  <pre><code>In [1]: df
  Out[1]:
  
                           A        B         C
  TIME
  2014-01-02 14:00:00 -1.172285  1.706200    NaN
  2014-01-02 14:05:00  0.039511 -0.320798    NaN
  2014-01-02 14:10:00 -0.192179 -0.539397    NaN
  2014-01-02 14:15:00 -0.475917 -0.280055    NaN
  2014-01-02 14:20:00  0.163376  1.124602    NaN
  2014-01-02 14:25:00 -2.477812  0.656750    NaN
  </code></pre>
  
  <p>I have tried all of the below statements to create sdf as view for my time range:</p>
  
  <pre><code>start = datetime.strptime('2014-01-02 14:07:00', '%Y-%m-%d %H:%M:%S')
  end = datetime.strptime('2014-01-02 14:22:00', '%Y-%m-%d %H:%M:%S')
  
  sdf = df[start:end]
  sdf = df[start &lt; df.index &lt; end]
  sdf = df.ix[start:end]
  sdf = df.loc[start:end]
  sdf = df.truncate(before=start, after=end, copy=False)
  
  sdf[C] == 100
  </code></pre>
  
  <p>Most return a copy and I get a SettingWithCopyWarning warning. The loc function says the index is incompatible with datetime. Is this something I should be able to do. The result I would like after updating the slice is:</p>
  
  <pre><code>In [1]: df
  Out[1]:
  
                           A        B         C
  TIME
  2014-01-02 14:00:00 -1.172285  1.706200    NaN
  2014-01-02 14:05:00  0.039511 -0.320798    NaN
  2014-01-02 14:10:00 -0.192179 -0.539397    100
  2014-01-02 14:15:00 -0.475917 -0.280055    100
  2014-01-02 14:20:00  0.163376  1.124602    100
  2014-01-02 14:25:00 -2.477812  0.656750    NaN
  </code></pre>
  
  <p>Can anyone please suggest a way to this? Am I approaching this the wrong way?</p>
  
  <p>Thanks</p>