Creating new column in pandas DataFrame gives SettingwithCopyWarning

تعرفه تبلیغات در سایت

آرشیو مطالب

امکانات وب

Vote count: 0

I've created a model using sklearn and want to set the predicted values from that model as a new column in an existing DataFrame. It works, but it results in the warning: /home/.conda//lib/python3.6/site-packages/ipykernel/__main__.py:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead How can I avoid this? Below is my code:

import pandas as pd
from sklearn.ensemble import GradientBoostingRegressor

gbm_model = GradientBoostingRegressor().fit(Xtrn[predictors], Ytrn)
Xtst['gbm_pred'] = gbm_model.predict(Xtst[predictors])
asked 1 min ago
Gaurav Bansal

نویسنده : استخدام کار بازدید : 0 تاريخ : جمعه 25 اسفند 1396 ساعت: 1:52
برچسب‌ها :

خبرنامه

عضویت

نام کاربري :
رمز عبور :