title: Python DatetimeIndex Error - TypeError: ("cannot do label indexing on <class 'pandas.tseries.index.DatetimeIndex'
body: <p>I have so far the following code provided by EdChum:</p>
  
  <pre><code>In [1]:
  df = pd.DataFrame({'a': [None] * 6, 'b': [2, 3, 10, 3, 5, 8]})
  df["c"] =np.NaN
  
  df["c"][0] = 1
  df["c"][2] = 3
  
  
  def func(x):
      if pd.notnull(x['c']):
          return x['c']
      else:
          return df.iloc[x.name - 1]['c'] * x['b']
  df['c'] = df.apply(func, axis =1)
  df['c'] = df.apply(func, axis =1)
  df['c'] = df.apply(func, axis =1)
  df
  
  Out[1]:
        a   b    c
  0  None   2    1
  1  None   3    3
  2  None  10    3
  3  None   3    9
  4  None   5   45
  5  None   8  360
  </code></pre>
  
  <p>That also works perfectly well, but as soon as I change the index of the dateframe = df as follows:</p>
  
  <pre><code>rng = pd.date_range('1/1/2011', periods=6, freq='D')
  
  df = pd.DataFrame({'a': [None] * 6, 'b': [2, 3, 10, 3, 5, 8]},index=rng)
  </code></pre>
  
  <p>I get the following error: <code>TypeError: ("cannot do label indexing on &lt;class 'pandas.tseries.index.DatetimeIndex'&gt; with these indexers [2011-01-01 00:00:00] of &lt;class 'pandas.tslib.Timestamp'&gt;", u'occurred at index 2011-01-02 00:00:00')
  </code> </p>
  
  <p>What is the problem here? How do I need to adjust the code in order to make it work with da DatetimeIndex?</p>