Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix write out type conversion #133

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lasso/roadway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down