Skip to content

Commit

Permalink
Handle NA values in integer columns in risk_factor flow
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentAntoine committed Sep 27, 2021
1 parent 19bece3 commit db1c1a5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions datascience/src/pipeline/flows/risk_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ def compute_risk_factors(
)
)

risk_factors = risk_factors.astype(
{
"number_controls_last_3_years": int,
"number_controls_last_5_years": int,
"number_diversions_last_5_years": int,
"number_escorts_to_quay_last_5_years": int,
"number_infractions_last_5_years": int,
"number_recent_controls": int,
"number_seizures_last_5_years": int,
}
)

def float_or_na_to_str(float_or_na) -> str:
if pd.isna(float_or_na):
return ""
else:
return str(int(float_or_na))

risk_factors["vessel_id"] = risk_factors.vessel_id.map(float_or_na_to_str)

return risk_factors


Expand Down

0 comments on commit db1c1a5

Please sign in to comment.