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:
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])