Skip to content

Commit 95ded64

Browse files
leestottCopilot
andauthored
Update 2-Working-With-Data/08-data-preparation/notebook.ipynb
Co-authored-by: Copilot <[email protected]>
1 parent c7982ed commit 95ded64

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

2-Working-With-Data/08-data-preparation/notebook.ipynb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,18 +3909,21 @@
39093909
"metadata": {},
39103910
"outputs": [],
39113911
"source": [
3912-
"from scipy import stats\n",
3913-
"\n",
3914-
"# Calculate Z-scores for age\n",
3915-
"dirty_data['age_zscore'] = np.abs(stats.zscore(dirty_data['age']))\n",
3912+
"try:\n",
3913+
" from scipy import stats\n",
3914+
"except ImportError:\n",
3915+
" print(\"scipy is required for Z-score calculation. Please install it with 'pip install scipy' and rerun this cell.\")\n",
3916+
"else:\n",
3917+
" # Calculate Z-scores for age\n",
3918+
" dirty_data['age_zscore'] = np.abs(stats.zscore(dirty_data['age']))\n",
39163919
"\n",
3917-
"# Typically, Z-score > 3 indicates an outlier\n",
3918-
"print(\"Rows with age Z-score > 3:\")\n",
3919-
"zscore_outliers = dirty_data[dirty_data['age_zscore'] > 3]\n",
3920-
"print(zscore_outliers[['customer_id', 'name', 'age', 'age_zscore']])\n",
3920+
" # Typically, Z-score > 3 indicates an outlier\n",
3921+
" print(\"Rows with age Z-score > 3:\")\n",
3922+
" zscore_outliers = dirty_data[dirty_data['age_zscore'] > 3]\n",
3923+
" print(zscore_outliers[['customer_id', 'name', 'age', 'age_zscore']])\n",
39213924
"\n",
3922-
"# Clean up the temporary column\n",
3923-
"dirty_data = dirty_data.drop('age_zscore', axis=1)"
3925+
" # Clean up the temporary column\n",
3926+
" dirty_data = dirty_data.drop('age_zscore', axis=1)"
39243927
]
39253928
},
39263929
{

0 commit comments

Comments
 (0)