Statsmodels:需要没有 NaN 或 Infs 的数组 - 但测试显示没有 NaNs 或 Infs

Statsmodels: requires arrays without NaN or Infs - but test shows there are no NaNs or Infs

我正在尝试 运行 来自 statsmodels 的 adfuller 模块的 ADF 测试。它给了我一个错误:

ValueError: array must not contain infs or NaNs

通过另一个问题我可以替换我的 NaNs (.

尽管我检查了 NaN 和 inf:

df[pd.isnull(df).any(axis=1)]
np.isinf(df).any()
np.isnan(df).any()

"no results" pandas 语句和 "false" numpy 语句,我的函数仍然告诉我同样的错误。

有bug吗?

我现在已经解决了:

 x = pd.DataFrame(x.replace([np.inf, -np.inf], np.nan))
 x = x.fillna(method='ffill')
 x = x.fillna(method='bfill')
 x = x.iloc[:, 0]

这给了我一个没有任何 nan of inf 的 x 系列。问题是从系列到数据框的切换,再回到系列