diff --git a/lasso/roadway.py b/lasso/roadway.py index 07f044d..c2ac1df 100644 --- a/lasso/roadway.py +++ b/lasso/roadway.py @@ -1112,12 +1112,19 @@ def convert_int(self, int_col_names=[]): # int_col_names.remove("lanes") for c in list(set(self.links_df.columns) & set(int_col_names)): + self.links_df[c] = self.links_df[c].replace(np.nan, 0) + # REPLACE BLANKS WITH ZERO FOR INTEGER COLUMNS + self.links_df[c] = self.links_df[c].replace('', 0) try: - self.links_df[c] = self.links_df[c].replace(np.nan, 0) - self.links_df[c] = self.links_df[c].astype(int) - except: - self.links_df[c] = self.links_df[c].astype(float) self.links_df[c] = self.links_df[c].astype(int) + except ValueError: + try: + self.links_df[c] = self.links_df[c].astype(float) + self.links_df[c] = self.links_df[c].astype(int) + except: + msg = f"Could not convert column {c} to integer." + WranglerLogger.error(msg) + raise ValueError(msg) for c in list(set(self.nodes_df.columns) & set(int_col_names)): self.nodes_df[c] = self.nodes_df[c].astype(int)