Complete the code to difference the time series data once.
differenced_series = original_series[1]The .diff() function calculates the difference between consecutive values, which helps to make a time series stationary.
Complete the code to check if the time series is stationary using the Augmented Dickey-Fuller test.
from statsmodels.tsa.stattools import adfuller result = adfuller(time_series) print('p-value:', result[1])
The p-value is at index 1 in the result tuple returned by adfuller(). A low p-value indicates stationarity.
Fix the error in the code to difference the series twice.
diff2_series = original_series[1].diff()To difference twice, you apply diff() two times: .diff().diff(). Using diff(2) calculates the difference between values two steps apart, which is not the same.
Complete the code to difference the series once, drop NaNs, and print the p-value from the ADF test.
differenced = original_series.diff()[1] result = adfuller(differenced) print('p-value:', result[2])
.dropna(), causing errors in ADF test[0] (test statistic) instead of [1] (p-value)Differencing introduces NaN at the start, so chain .dropna() before running adfuller(). The p-value is result[1].
Fill all three blanks to extract the test statistic and p-value from the ADF test on differenced series, and reference critical values.
adf_result = adfuller(differenced_series[1]) test_stat = adf_result[2] p_value = adf_result[3] critical_vals = adf_result[4]
.dropna()Remove NaNs with .dropna(). The ADF result tuple has test statistic at index [0], p-value at [1], and critical values dictionary at [4].