Skip to content

Commit

Permalink
ignore first column (poi) for zero- checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ShengKungYi committed May 8, 2015
1 parent 812f6ac commit bfd3e51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/feature_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True
all the features you seek are 0.0
remove_any_zeroes=True will omit any data points for which
any of the features you seek are 0.0
NOTE: first feature is assumed to be 'poi' and is not checked for
removal for zero or missing values.
"""


Expand Down Expand Up @@ -69,15 +71,15 @@ def featureFormat( dictionary, features, remove_NaN=True, remove_all_zeroes=True
### data points that are all zero, do that here
if remove_all_zeroes:
append = False
for item in tmp_list:
for item in tmp_list[1:]:
if item != 0 and item != "NaN":
append = True
break
### if any features for a given data point are zero
### and you want to remove data points with any zeroes,
### handle that here
if remove_any_zeroes:
if 0 in tmp_list or "NaN" in tmp_list:
if 0 in tmp_list[1:] or "NaN" in tmp_list[1:]:
append = False
### Append the data point if flagged for addition.
if append:
Expand Down

0 comments on commit bfd3e51

Please sign in to comment.