I want to know which line or method caused the Future Warning!
predictors = weekly.columns[1:7] # the lags and volume
X = sm.add_constant(weekly[predictors]) # sm: statsmodels
y = np.array([1 if el=='Up' else 0 for el in weekly.Direction.values])
logit = sm.Logit(y,X)
results=logit.fit()
print(results.summary())
C:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py:2389: FutureWarning: Method .ptp is deprecated and will be removed in a future version. Use numpy.ptp instead. return ptp(axis=axis, out=out, **kwargs)
weekly[predictors]
will return a Series representation of the weekly[[predictors]]
DataFrame. Since the warning tells to use numpy.ptp
, then by adding the attribute values
to weekly[predictors]
will make the warning disappeared, i.e.
X = sm.add_constant(weekly[predictors].values)
or you can use the method to_numpy()
:
X = sm.add_constant(weekly[predictors].to_numpy())
It will convert the weekly[predictors]
Series to a NumPy array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With