Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FutureWarning: Method .ptp

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)

like image 409
Van Cheng Avatar asked May 26 '19 05:05

Van Cheng


1 Answers

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.

like image 74
Anastasiya-Romanova 秀 Avatar answered Oct 06 '22 13:10

Anastasiya-Romanova 秀