<jupyter_start><jupyter_text>Testing stationarity<jupyter_code>from statsmodels.tsa.stattools import adfuller

def test_adf(series, title=''):
    dfout={}
    dftest=sm.tsa.adfuller(series.dropna(), autolag='AIC', regression='ct')
    for key,val in dftest[4].items():
        dfout[f'critical value ({key})']=val
    if dftest[1]<=0.05:
        print("Strong evidence against Null Hypothesis")
        print("Reject Null Hypothesis - Data is Stationary")
        print("Data is Stationary", title)
    else:
        print("Strong evidence for  Null Hypothesis")
        print("Accept Null Hypothesis - Data is not Stationary")
        print("Data is NOT Stationary for", title)
cleanDF = trainDF.dropna()
cleanDF
cleanDF.diff()
test_adf(cleanDF, "Numero de infectados")
test_adf(cleanDF.diff(), "Numero de infectados")<jupyter_output>Strong evidence for  Null Hypothesis
Accept Null Hypothesis - Data is not Stationary
Data is NOT Stationary for Numero de infectados
{'fraction_non_alphanumeric': 0.1115702479338843, 'fraction_numerical': 0.005165289256198347, 'mean_word_length': 4.324175824175824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '389531', 'license': 'MIT', 'n_tokens_mistral': 324, 'n_tokens_neox': 311, 'n_words': 86, 'path': 'Forecasting covid19 chile.ipynb', 'repo_name': 'rpmunoz/covid19', 'size': '968'}