当我运行下面的代码时,我收到特定警告
import numpy as np
from statsmodels.tsa.stattools import kpss
kpss(np.random.choice(range(-1000,1000),10000))
警告信息
<stdin>:1: InterpolationWarning: The test statistic is outside of the range of p-values available in the
look-up table. The actual p-value is greater than the p-value returned.
是否可以仅忽略此警告,而不影响代码文件其他部分中可能出现的任何其他警告的显示
一种方法是通过从
warning
导入 InterpolationWarning
模块和 statsmodels.tools.sm_exceptions
来静音插值警告:
import warnings
from statsmodels.tools.sm_exceptions import InterpolationWarning
warnings.simplefilter('ignore', InterpolationWarning)
现在,运行:
import numpy as np
from statsmodels.tsa.stattools import kpss
kpss(np.random.choice(range(-1000,1000),10000))
输出
(0.269901614649574,
0.1,
11,
{'10%': 0.347, '5%': 0.463, '2.5%': 0.574, '1%': 0.739})