Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
df_telco_transformed = df_telco.copy()
# label encoding (binary variables)
label_encoding_columns = ['gender', 'Partner', 'Dependents', 'PaperlessBilling', 'PhoneService', 'Churn']
# encode categorical binary features using label encoding
for column in label_encoding_columns:
if column == 'gender':
df_telco_transformed[column] = df_telco_transformed[column].map({'Female': 1, 'Male': 0})
df_telco_transformed[column] = df_telco_transformed[column].map({'Yes': 1, 'No': 0})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment