From d80cfc9d347882b219ec0da99ce9cd52c83cc626 Mon Sep 17 00:00:00 2001 From: Mary Sarafraz <42359555+msarafraz@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:40:49 -0500 Subject: [PATCH] Update tutorial-data-science-explore-notebook.md added df_clean['Exited'] = df_clean['Exited'].astype(str) and df_clean['Tenure'] = df_clean['Tenure'].astype(int) to remove errors --- docs/data-science/tutorial-data-science-explore-notebook.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/data-science/tutorial-data-science-explore-notebook.md b/docs/data-science/tutorial-data-science-explore-notebook.md index a132a010d1..0e9f117620 100644 --- a/docs/data-science/tutorial-data-science-explore-notebook.md +++ b/docs/data-science/tutorial-data-science-explore-notebook.md @@ -165,6 +165,7 @@ Show the distribution of exited versus nonexited customers across the categorica ```python attr_list = ['Geography', 'Gender', 'HasCrCard', 'IsActiveMember', 'NumOfProducts', 'Tenure'] +df_clean['Exited'] = df_clean['Exited'].astype(str) fig, axarr = plt.subplots(2, 3, figsize=(15, 4)) for ind, item in enumerate (attr_list): sns.countplot(x = item, hue = 'Exited', data = df_clean, ax = axarr[ind%2][ind//2]) @@ -198,6 +199,7 @@ plt.show() Perform feature engineering to generate new attributes based on current attributes: ```python +df_clean['Tenure'] = df_clean['Tenure'].astype(int) df_clean["NewTenure"] = df_clean["Tenure"]/df_clean["Age"] df_clean["NewCreditsScore"] = pd.qcut(df_clean['CreditScore'], 6, labels = [1, 2, 3, 4, 5, 6]) df_clean["NewAgeScore"] = pd.qcut(df_clean['Age'], 8, labels = [1, 2, 3, 4, 5, 6, 7, 8])