From 7e0607de07251ff69cafb8f87a1924b85df790bd Mon Sep 17 00:00:00 2001 From: JulianForeman <71847719+JulianForeman@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:47:09 -0700 Subject: [PATCH] Added check for string length being long enough to apply lambda function to prevent errors (#380) --- django/api/services/spreadsheet_uploader_prep.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/api/services/spreadsheet_uploader_prep.py b/django/api/services/spreadsheet_uploader_prep.py index 91c1c03c..0b93eabb 100644 --- a/django/api/services/spreadsheet_uploader_prep.py +++ b/django/api/services/spreadsheet_uploader_prep.py @@ -173,8 +173,10 @@ def make_prepositions_consistent(df): regex=True ) ##The first letter should be capitalized - df[['Applicant Name', 'Manufacturer']] = df[['Applicant Name', 'Manufacturer'] - ].applymap(lambda x: x[0].upper() + x[1:]) + df[['Applicant Name', 'Manufacturer']] = df[['Applicant Name', 'Manufacturer']].applymap( + lambda x: x[0].upper() + x[1:] if isinstance(x, str) and len(x) > 1 else x.upper() if isinstance(x, str) and len(x) == 1 else x +) + def adjust_ger_manufacturer_names(df): """""