I have got a time series with a float index representing minutes from start of an experiment. The observations are not perfectly equally spaced. I am doing a rolling mean. Here some example data:
S = pd.Series([0,3,2,6,4,7,7,9,11,13,12,12,11,9,6,7,3,5,4],
index=[0.01,0.13,0.2,0.29,0.4,0.5,0.59,0.68,0.79,0.9,1.0,1.1,1.19,1.29,1.4,1.5,1.6,1.71,1.8])
Sr = S.rolling(3, win_type='triang', center=True).mean()
In my real data the window spans several hundred data points. Thus, i would like it to always span the same time (in index units), instead of a fixed number of observations. I found that this is possible on datetime indexes, however I need the index to be float for further calculation. Is there any way of doing this without having to convert the index to datetime and back again?
Pseudo-function:
Sr = S.rolling(0.3, win_type='triang', center=True, *on=index*).mean()
Expected output for this example:
for each index i: mean over window from i-0.15 to i+0.15 (with triangular weighting according to distance from i)