title: Python pandas dataframe - any way to set frequency programmatically?
body: <p>I'm trying to process CSV files like this:</p>
  
  <pre><code>df = pd.read_csv("raw_hl.csv", index_col='time', parse_dates = True))
  df.head(2)
                      high        low 
  time                
  2014-01-01 17:00:00 1.376235    1.375945
  2014-01-01 17:01:00 1.376005    1.375775
  2014-01-01 17:02:00 1.375795    1.375445
  2014-01-01 17:07:00 NaN         NaN 
  ...
  2014-01-01 17:49:00 1.375645    1.375445
  
  type(df.index)
  pandas.tseries.index.DatetimeIndex
  </code></pre>
  
  <p>But these don't automatically have a frequency:</p>
  
  <pre><code>print df.index.freq
  None
  </code></pre>
  
  <p>In case they have differing frequencies, it would be handy to be able to set one automatically. The simplest way would be to compare the first two rows:</p>
  
  <pre><code>tdelta = df.index[1] - df.index[0]
  tdelta
  datetime.timedelta(0, 60) 
  </code></pre>
  
  <p>So far so good, but setting frequency directly to this timedelta fails:</p>
  
  <pre><code>df.index.freq = tdelta
  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-25-3f24abacf9de&gt; in &lt;module&gt;()
  ----&gt; 1 df.index.freq = tdelta
  
  AttributeError: can't set attribute
  </code></pre>
  
  <p>Is there a way (ideally relatively painless!) to do this?</p>
  
  <p>ANSWER: Pandas has given the dataframe has a index.inferred_freq attribute - perhaps to avoid overwriting a user defined frequency.
  df.index.inferred_freq = 'T'</p>
  
  <p>So it just seems to be a matter of using this instead of df.index.freq. Thanks to Jeff, who also provides more details below :)</p>