implementation of nan-friendly moving window functions and may be worth looking at depending on your application exponentially-weighted functions an alternative to using static window size with equally-weighted observations is to specify constant decay factor to give more weight to more recent observations in mathematical termsif mat is the moving average result at time and is the time series in questioneach value in the result is computed as mat mat ( x_twhere is the decay factor there are couple of ways to specify the decay factora popular one is using spanwhich makes the result comparable to simple moving window function with window size equal to the span since an exponentially-weighted statistic places more weight on more recent observationsit "adaptsfaster to changes compared with the equal-weighted version here' an example comparing -day moving average of apple' stock price with an ew moving average with span= (see figure - )figaxes plt subplots(nrows= ncols= sharex=truesharey=truefigsize=( )aapl_px close_px aapl[' ':' 'ma pd rolling_mean(aapl_px min_periods= ewma pd ewma(aapl_pxspan= aapl_px plot(style=' -'ax=axes[ ]ma plot(style=' --'ax=axes[ ]aapl_px plot(style=' -'ax=axes[ ]ewma plot(style=' --'ax=axes[ ]axes[ set_title('simple ma'axes[ set_title('exponentially-weighted ma'binary moving window functions some statistical operatorslike correlation and covarianceneed to operate on two time series as an examplefinancial analysts are often interested in stock' correlation to benchmark index like the & we can compute that by computing the percent changes and using rolling_corr (see figure - )in [ ]spx_rets spx_px spx_px shift( in [ ]returns close_px pct_change(in [ ]corr pd rolling_corr(returns aaplspx_rets min_periods= in [ ]corr plot( time series www it-ebooks info