Fixed nan issues.

parent b5ea0ecf
...@@ -7,6 +7,7 @@ Created on Wed Nov 10 11:52:54 2021 ...@@ -7,6 +7,7 @@ Created on Wed Nov 10 11:52:54 2021
import pandas as pd import pandas as pd
import sys import sys
import math
''' '''
datafile_path = sys.argv[1] datafile_path = sys.argv[1]
csv_separator = "," csv_separator = ","
...@@ -43,14 +44,14 @@ def numeric_conversion(datafile): ...@@ -43,14 +44,14 @@ def numeric_conversion(datafile):
for col in verify_num_col: for col in verify_num_col:
datafile[col] = [float(x) for x in datafile[col]] datafile[col] = [float(x) if not math.isnan(x) else None for x in datafile[col]]
verify_cat_col = [x for x in datafile.columns if x in categorical_variables] verify_cat_col = [x for x in datafile.columns if x in categorical_variables]
for col in verify_cat_col: for col in verify_cat_col:
datafile[col] = [str(x) for x in datafile[col]] datafile[col] = [str(x) if not math.isnan(x) else None for x in datafile[col]]
#new_datafile_path = datafile_path.replace(".csv", "_numeric.csv") #new_datafile_path = datafile_path.replace(".csv", "_numeric.csv")
#datafile.to_csv(new_datafile_path, index = False, quoting=csv.QUOTE_NONNUMERIC) #datafile.to_csv(new_datafile_path, index = False, quoting=csv.QUOTE_NONNUMERIC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment