smoothing techniques as discussed in the previous preprocessing the raw data depends upon the data as well as the use case requirements yet there are certain standard preprocessing techniques for each type of data unlike the datasets we have seen so farwhere we consider each observation to be independent of other (past or futureobservationstime series have inherent dependency on historical observations as seen from the decomposition of web site visits seriesthere are multiple factors impacting each observation it is an inherent property of time series data to have random variation to it apart from its other constituents to better understandmodeland utilize time series for prediction related taskswe usually perform preprocessing step better termed as smoothing smoothing helps reduce the effect of random variation and helps clearly reveal the seasonalitytrendand residual components of the series there are various methods to smooth out time series they are broadly categorized as follows moving average instead of taking an average of complete time series (which we do in cases of non-temporal datato summarizemoving average makes use of rolling windowed approach in this casewe compute the mean of each successive smaller windows of past data to smoothen out the impact of random variation the following is general formula for moving average calculation mat xt xt - xt - / xt - wheremat is the moving average for time period txtxt- and so on denote observed values at particular time periodsand is the window size for examplethe following snippet calculates the moving average for visits with window size of in [ moving average input_df['moving_average'input_df['visits'rolling(window= center=falsemean(print(input_df[['visits','moving_average']head( )plt plot(input_df visits,'-',color='black',alpha= plt plot(input_df moving_average,color=' 'plt title('website visit and moving average smoothening'plt legend(plt show(the moving average calculated using window size has the following results it should be pretty clear that for window size of the first two observations would not have any moving averages availablehence the nan out[ ]visits moving_average nan nan