Skip to content

Commit

Permalink
Add note about special case with mode NA replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiever authored Jan 18, 2017
1 parent 44bcd70 commit 5572555
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion datacleaner/datacleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def autoclean(input_dataframe, drop_nans=False, copy=False, encoder=None,
input_dataframe[column].fillna(input_dataframe[column].median(), inplace=True)
except TypeError:
most_frequent = input_dataframe[column].mode()
if len(most_frequent)>0:
# If the mode can't be computed, use the nearest valid value
# See https://github.com/rhiever/datacleaner/issues/8
if len(most_frequent) > 0:
input_dataframe[column].fillna(input_dataframe[column].mode()[0], inplace=True)
else:
input_dataframe[column].fillna(method='bfill', inplace=True)
Expand Down

0 comments on commit 5572555

Please sign in to comment.