saherPervaiz commited on
Commit
98aea7e
·
verified ·
1 Parent(s): f8a4ded

Update utils/data_cleaning.py

Browse files
Files changed (1) hide show
  1. 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
- if method == "Drop rows":
11
- df = df.dropna()
12
- elif method == "Fill with mean/median":
13
- for col in df.columns:
14
- if df[col].dtype in ['float64', 'int64']:
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):