Spaces:
Sleeping
Sleeping
Update utils/data_cleaning.py
Browse files- utils/data_cleaning.py +5 -8
utils/data_cleaning.py
CHANGED
|
@@ -7,14 +7,11 @@ def preprocess_data(df):
|
|
| 7 |
Preprocess the dataset by handling missing values and performing any necessary cleanup.
|
| 8 |
"""
|
| 9 |
# Example: Handling missing values by filling with column mean
|
| 10 |
-
|
| 11 |
-
df
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
df[col].fillna(df[col].mean(), inplace=True)
|
| 16 |
-
else:
|
| 17 |
-
df[col].fillna(df[col].mode()[0], inplace=True)
|
| 18 |
return df
|
| 19 |
|
| 20 |
def remove_outliers_iqr(df):
|
|
|
|
| 7 |
Preprocess the dataset by handling missing values and performing any necessary cleanup.
|
| 8 |
"""
|
| 9 |
# Example: Handling missing values by filling with column mean
|
| 10 |
+
for col in df.columns:
|
| 11 |
+
if df[col].dtype in ['float64', 'int64']:
|
| 12 |
+
df[col].fillna(df[col].mean(), inplace=True)
|
| 13 |
+
else:
|
| 14 |
+
df[col].fillna(df[col].mode()[0], inplace=True)
|
|
|
|
|
|
|
|
|
|
| 15 |
return df
|
| 16 |
|
| 17 |
def remove_outliers_iqr(df):
|