Package for time series analysis in python [closed] Package for time series analysis in python [closed] pandas pandas

Package for time series analysis in python [closed]


Pandas has exponentially weighted moving moment functions

http://pandas.pydata.org/pandas-docs/dev/computation.html?highlight=exponential#exponentially-weighted-moment-functions

By the way, there shouldn't be any functionality leftover in the scikits.timeseries package that is not also in pandas.

Edit: Since this is still a popular question, there is now a work in progress pull request to add more fully featured exponential smoothing to statsmodels here


Somehow some questions got merged or deleted, so I'll post my answer here.

Exp smoothing in Python natively.

'''simple exponential smoothinggo back to last N valuesy_t = a * y_t + a * (1-a)^1 * y_t-1 + a * (1-a)^2 * y_t-2 + ... + a*(1-a)^n * y_t-n'''from random import random,randintdef gen_weights(a,N):    ws = list()    for i in range(N):        w = a * ((1-a)**i)        ws.append(w)    return wsdef weighted(data,ws):    wt = list()    for i,x in enumerate(data):        wt.append(x*ws[i])    return wtN = 10a = 0.5ws = gen_weights(a,N)data = [randint(0,100) for r in xrange(N)]weighted_data = weighted(data,ws)print 'data: ',dataprint 'weights: ',wsprint 'weighted data: ',weighted_dataprint 'weighted avg: ',sum(weighted_data)


you can predict the future values using Pandas Exponentially-weighted moving average http://pandas.pydata.org/pandas-docs/stable/generated/pandas.stats.moments.ewma.html as

from pandas.stats.moments import ewmaimport numpy as nppred_period = 12def predict(x,span,periods = pred_period):         x_predict = np.zeros((span+periods,))    x_predict[:span] = x[-span:]    pred =  ewma(x_predict,span)[span:]    return pred