How do I implement sliding window algorithm with a window size of 10 and visualize the data iteratively to see spikes/possible outliers in the dataframe, using python? Please help a beginner.

  • 1
    $\begingroup$ Are you actually looking for an algorithm that detects spikes (anomaly detection), or simply a way to visualize data 10 observations at a time to manually look for spikes in the data? $\endgroup$
    – Ryan
    Commented May 31, 2018 at 16:47
  • $\begingroup$ $There are gems$ -: “Open Machine Learning Course. Topic 9. Part 1. Time series analysis in Python” medium.com/open-machine-learning-course/…,“Open Machine Learning Course. Topic 9. Part 2. Predicting the future with Facebook Prophet” medium.com/open-machine-learning-course/… $\endgroup$
    – Aditya
    Commented May 31, 2018 at 16:54
  • $\begingroup$ Thanks @Aditya the resource you provided was extremely helpful! Ryan, I am looking to detect random spikes on data and smoothen them out, as well as to visualize them in smaller windows. $\endgroup$
    – natg
    Commented May 31, 2018 at 19:11

1 Answer 1


welcome to DS-SE and to Data Science in general! :)

Your problem can be solved really easily in Python. Please, take a look at Pandas DataFrame class to represent your data, it makes it really convenient because of all the pre-built methods that includes.

One of its methods is pandas.DataFrame.rolling() (see here) that does exactly what you asked for: rolling (sliding) window calculations, please take a look!

Hope it helps!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.