Spaces:
Running
Running
Commit
·
f0b0078
1
Parent(s):
dd1cbb4
added check that ref_df has at least one row for one rename step
Browse files- tools/matcher_funcs.py +25 -22
tools/matcher_funcs.py
CHANGED
@@ -395,6 +395,8 @@ def check_ref_data_exists(Matcher:MatcherClass, ref_data_state:PandasDataFrame,
|
|
395 |
|
396 |
# For the neural net model to work, the llpg columns have to be in the LPI format (e.g. with columns SaoText, SaoStartNumber etc. Here we check if we have that format.
|
397 |
|
|
|
|
|
398 |
if 'Address_LPI' in Matcher.ref_df.columns:
|
399 |
Matcher.ref_df = Matcher.ref_df.rename(columns={
|
400 |
"Name_LPI": "PaoText",
|
@@ -416,28 +418,29 @@ def check_ref_data_exists(Matcher:MatcherClass, ref_data_state:PandasDataFrame,
|
|
416 |
#print("Matcher reference file: ", Matcher.ref_df['Reference file'])
|
417 |
|
418 |
# Check if the source is the Addressbase places API
|
419 |
-
if Matcher.ref_df
|
420 |
-
Matcher.ref_df
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
|
|
441 |
|
442 |
# Check ref_df file format
|
443 |
# If standard format, or it's an API call
|
|
|
395 |
|
396 |
# For the neural net model to work, the llpg columns have to be in the LPI format (e.g. with columns SaoText, SaoStartNumber etc. Here we check if we have that format.
|
397 |
|
398 |
+
|
399 |
+
|
400 |
if 'Address_LPI' in Matcher.ref_df.columns:
|
401 |
Matcher.ref_df = Matcher.ref_df.rename(columns={
|
402 |
"Name_LPI": "PaoText",
|
|
|
418 |
#print("Matcher reference file: ", Matcher.ref_df['Reference file'])
|
419 |
|
420 |
# Check if the source is the Addressbase places API
|
421 |
+
if len(Matcher.ref_df) > 0:
|
422 |
+
if Matcher.ref_df.iloc[0]['Reference file'] == 'API' or '_api_' in Matcher.ref_df.iloc[0]['Reference file']:
|
423 |
+
Matcher.ref_df = Matcher.ref_df.rename(columns={
|
424 |
+
"ORGANISATION_NAME": "Organisation",
|
425 |
+
"ORGANISATION": "Organisation",
|
426 |
+
"PAO_TEXT": "PaoText",
|
427 |
+
"PAO_START_NUMBER": "PaoStartNumber",
|
428 |
+
"PAO_START_SUFFIX":"PaoStartSuffix",
|
429 |
+
"PAO_END_NUMBER":"PaoEndNumber",
|
430 |
+
"PAO_END_SUFFIX":"PaoEndSuffix",
|
431 |
+
"STREET_DESCRIPTION":"Street",
|
432 |
+
|
433 |
+
"SAO_TEXT":"SaoText",
|
434 |
+
"SAO_START_NUMBER":"SaoStartNumber",
|
435 |
+
"SAO_START_SUFFIX":"SaoStartSuffix",
|
436 |
+
"SAO_END_NUMBER":"SaoEndNumber",
|
437 |
+
"SAO_END_SUFFIX":"SaoEndSuffix",
|
438 |
+
|
439 |
+
"POSTCODE_LOCATOR":"Postcode",
|
440 |
+
"TOWN_NAME":"PostTown",
|
441 |
+
"LOCALITY_NAME":"LocalityName",
|
442 |
+
"ADMINISTRATIVE_AREA":"AdministrativeArea"
|
443 |
+
}, errors="ignore")
|
444 |
|
445 |
# Check ref_df file format
|
446 |
# If standard format, or it's an API call
|