Skip to content

Commit

Permalink
fix: adds filllna to 0 for numeric columns (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
emi-hi authored Nov 28, 2023
1 parent df0158e commit fb9d0c6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion django/api/services/speciality_use_vehicle_incentives.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pandas as pd
import numpy as np
from api.models.speciality_use_vehicle_incentives import \
SpecialityUseVehicleIncentives

Expand Down Expand Up @@ -36,9 +37,14 @@ def import_from_xls(excel_file):
"Model",
]), 1, inplace=True)
df = trim_all_columns(df)
## find the columns that contain numbers and replace blank balues with 0
num_columns = df.select_dtypes(include=np.number).columns.tolist()
num_columns.remove('Applicant Name')
df[num_columns] = df[num_columns].fillna(0)
## all other columns get a null value
df = df.fillna('')
df = df.applymap(lambda s: s.upper() if type(s) == str else s)
df['Applicant Type'] = df.apply(lambda row: applicant_type(row), axis=1)
df.fillna('')

for _, row in df.iterrows():
try:
Expand Down

0 comments on commit fb9d0c6

Please sign in to comment.