from sklearn.preprocessing import LabelEncoder
object_cols = ['Gender', 'Married', 'Dependents', 'Education', 'Self_Employed', 'Credit_History', 'Property_Area', 'Loan_Status']
label_encoder = LabelEncoder()
for col in object_cols:
filtered_dataset[col] = label_encoder.fit_transform(filtered_dataset[col])
After running this code, it come out with this warning
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
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
filtered_dataset[col] = label_encoder.fit_transform(filtered_dataset[col])
I have tried many types of label encoder I know but still come up with this warning. How to settle with this warning?
I have tried many types of label encoder I know but still come up with this warning. How to settle with this warning?