Exercise

# Other tranforms

Differencing should be the first transform you try to make a time series stationary. But sometimes it isn't the best option.

A classic way of transforming stock time series is the log-return of the series. This is calculated as follows: $$log\_return ( y_t ) = log \left( \frac{y_t}{y_{t-1}} \right)$$

The Amazon stock time series has already been loaded for you as `amazon`

. You can calculate the log-return of this DataFrame by substituting:

- \(y_t \rightarrow\)
`amazon`

- \(y_{t-1} \rightarrow\)
`amazon.shift(1)`

- \(log() \rightarrow\)
`np.log()`

In this exercise you will compare the log-return transform and the first order difference of the Amazon stock time series to find which is better for making the time series stationary.

Instructions 1/2

**undefined XP**

- Calculate the first difference of the time series
`amazon`

to test for stationarity and drop the`NaN`

s.