Closed
Description
If your timeseries has a regularly spaced index, so if a frequency can be inferred, using asfreq
or resample
with this frequency does not set the frequency (it remains None):
In [1]: df = pd.DataFrame({'date':["2012-01-01", "2012-01-02", "2012-01-03"], 'col':[1,2,3]})
In [2]: df2 = df.set_index(pd.to_datetime(df.date))
In [3]: df2.index
Out[3]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-01-01 00:00:00, ..., 2012-01-03 00:00:00]
Length: 3, Freq: None, Timezone: None
In [4]: df2.index.inferred_freq
Out[4]: 'D'
In [5]: df2.asfreq('D').index
Out[5]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-01-01 00:00:00, ..., 2012-01-03 00:00:00]
Length: 3, Freq: None, Timezone: None
In [6]: df2.resample('D').index
Out[6]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-01-01 00:00:00, ..., 2012-01-03 00:00:00]
Length: 3, Freq: None, Timezone: None
Note: this is the same with a Series, however in 0.12 it works for Series (as then it is still a TimeSeries)