Discussions for article "A comprehensive beginner's guide to create a Time Series Forecast (with Codes in Python)"

Hi All,

The article “A comprehensive beginner’s guide to create a Time Series Forecast (with Codes in Python)” is quiet old now and you might not get a prompt response from the author.

We would request you to post your queries here to get them resolved.

A brief description of the article -

Time Series Analytics is considered to be one of the less known skills in the analytics space. This article covers Time Series Analysis concepts in an end-to-end manner along with codes in Python. The following steps are covered:

  1. What makes Time Series Special?
  2. Loading and Handling Time Series in Pandas
  3. How to Check Stationarity of a Time Series?
  4. How to make a Time Series Stationary?
  5. Forecasting a Time Series

Here I’m using Python 3.7.0. So some command is not running/causing error. Can you suggest me the replacement for that command which is causing the error.
a) why print is not supporting like print “abc” while your command is displaying as print “abc”.
b) command is not working “rolmean = pd.rolling_mean(timeseries,window=12)”
c) ‘pandas’ has no attribute ‘rolling_mean’
d)pd.ewma(ts_log, halflife=12)
please suggest alternate command for above error

Hi @santosh.gupta,

As the libraries have been updated, you have to make a little changes in the code:

Use print(abc)

Use df.rolling instead of rolling_mean. For more details, refer here.

Whom library is new? Mine or your? can you guide me what changes require. Thanks

Hi @santosh.gupta,

This article has been written a few months ago, so the libraries used in this are outdated. You must be working on the updated libraries so have to make a few changes in the codes.

Hello, This is sumanth and I am new to machine learning and modelling. I took a project based on Time Series for my masters academic subject project from analytics vidhya and can you guide me how to actually decrease the error in data(rmse score)? I just need the tips or how to model which could produce a good forecasting result.

Just in case you were not aware, check out AnticiPy which is an open-source tool for forecasting using Python and developed by Sky. The goal of AnticiPy is to provide reliable forecasts for a variety of time series data, while requiring minimal user effort .

AnticiPy can handle trend as well as multiple seasonality components, such as weekly or yearly seasonality. There is built-in support for holiday calendars, and a framework for users to define their own event calendars. The tool is tolerant to data with gaps and null values, and there is an option to detect outliers and exclude them from the analysis.

Ease of use has been one of our design priorities. A user with no statistical background can generate a working forecast with a single line of code, using the default settings. The tool automatically selects the best fit from a list of candidate models, and detects seasonality components from the data. Advanced users can tune this list of models or even add custom model components, for scenarios that require it.
There are also tools to automatically generate interactive plots of the forecasts (again, with a single line of code), which can be run on a Jupyter notebook, or exported as .html or .png files.

Check it out here:

Hello Jai,

Thank for the article on Time series on Analytics Vidhya. I followed the time series forecasting example till the “ewma” command. I am having issues with the new ewma command. Here is my code. Will you please look at it and let me know what could I change to get going further please?

xpwighted_avg = pd.ewma(ts_log, halflife=12)
plt.plot(expwighted_avg, color=‘red’)

Above three lines are vidhya’s code from the example.

expwavg = a.ewm(span=12).mean()


plt.plot(expwavg, color=‘red’)

The above 3 lines are my code… Appreciate any help.


It is a great example and I find it very useful. I am stuck with a business problem.
I have about 2000 store’s data for sales for 3 years. The business requirement is to forecast for 4 medicines from these 2000 stores individually and the client is expecting 8000 forecasts. Any pointers to how to go about it. I presented the idea of TKInter but the client prefers to have the forecasts with the measure of accuracy values for each store/medicine combination.

Hi, I am currently working on a time series forecasting project. I want to forecast Japans GDP and see how the unemployment rate affects the GDP and factor in birth rates too. I need help with the idea of this. Is this project sensible? How can I tie it all together and how should i approach this? Thank you.

when i try this code why am in getting NAN values.
predictions_ARIMA_log = pd.Series(ts_log.ix[0], index=ts_log.index)

any help would be appreciated

dftest = adfuller(timeseries)
while checking the stationarity in this line i am getting an error like ValueError: too many values to unpack (expected 2)

Very good introduction to Python ARIMA timeseries forecasting. Thank you!

Thanks for this comprehensive guide. It made me started time series. I have a question about ACF and PACF plot. Why upper and lower bounds of confidence intervals are chosen as z/sqrt(N)?

Dear All,

You need to change below codes for rolling mean and std to accommodate changes in pandas library.

rolmean = timeseries.rolling(12).mean()
rolstd = timeseries.rolling(12).std()

Above code snippet works in python 3.7
@PulkitS @santosh.gupta

© Copyright 2013-2021 Analytics Vidhya