thorodin103 commited on
Commit
f4e4229
·
verified ·
1 Parent(s): f06836c

Upload environment.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. environment.py +4 -1
environment.py CHANGED
@@ -219,7 +219,10 @@ class DataCleaningEnv:
219
  fill_val = numeric.median()
220
  self.current_df[c] = numeric.fillna(fill_val)
221
  elif strategy == "mode":
222
- fill_val = self.current_df[c].mode()[0]
 
 
 
223
  self.current_df[c] = self.current_df[c].fillna(fill_val)
224
  elif strategy == "ffill":
225
  self.current_df[c] = self.current_df[c].ffill()
 
219
  fill_val = numeric.median()
220
  self.current_df[c] = numeric.fillna(fill_val)
221
  elif strategy == "mode":
222
+ mode_vals = self.current_df[c].mode()
223
+ if len(mode_vals) == 0:
224
+ continue
225
+ fill_val = mode_vals.iloc[0]
226
  self.current_df[c] = self.current_df[c].fillna(fill_val)
227
  elif strategy == "ffill":
228
  self.current_df[c] = self.current_df[c].ffill()