1. Learn
  2. /
  3. Courses
  4. /
  5. ARIMA Models in Python

Exercise

Taking the difference

In this exercise, you will to prepare a time series of the population of a city for modeling. If you could predict the growth rate of a city then it would be possible to plan and build the infrastructure that the city will need later, thus future-proofing public spending. In this case the time series is fictitious but its perfect to practice on.

You will test for stationarity by eye and use the Augmented Dicky-Fuller test, and take the difference to make the dataset stationary.

The DataFrame of the time series has been loaded in for you as city and the adfuller() function has been imported.

Instructions 1/3

undefined XP
  • 1
    • Run the augmented Dicky-Fuller on the 'city_population' column of city.
    • Print the test statistic and the p-value.
  • 2
    • Take the first difference of city dropping the NaN values. Assign this to city_stationary and run the test again.
  • 3
    • Take the second difference of city, by applying the .diff() method twice and drop the NaN values.