Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,12 +74,24 @@ def map_names(odf,fname):
|
|
| 74 |
return mapped_frame,msg
|
| 75 |
|
| 76 |
def get_lob(df):
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
def get_paid_amount(df):
|
| 85 |
for col in df.columns:
|
|
|
|
| 74 |
return mapped_frame,msg
|
| 75 |
|
| 76 |
def get_lob(df):
|
| 77 |
+
global g_mapping
|
| 78 |
+
if g_mapping is None:
|
| 79 |
+
g_mapping = download_csv_as_dataframe('https://docs.google.com/spreadsheets/d/1rVoLrrTEDzU79x2H2Z1lJ7-z_jRbt-NMUdTarjLvSGo/edit?usp=drive_link')
|
| 80 |
+
mapping = g_mapping
|
| 81 |
+
|
| 82 |
+
column_names = set(df.columns)
|
| 83 |
+
best_match_col = None
|
| 84 |
+
max_matches = 0
|
| 85 |
+
for pattern in ["lob", "market_segment", "product", "class_of_business", 'type']:
|
| 86 |
+
matching_columns = {col for col in column_names if pattern in col.lower()}
|
| 87 |
+
|
| 88 |
+
for col in matching_columns:
|
| 89 |
+
matches = sum(df[col].isin(g_mapping['original']))
|
| 90 |
+
if matches > max_matches:
|
| 91 |
+
best_match_col = col
|
| 92 |
+
max_matches = matches
|
| 93 |
+
column_names -= matching_columns
|
| 94 |
+
return best_match_col if max_matches > 0 else None
|
| 95 |
|
| 96 |
def get_paid_amount(df):
|
| 97 |
for col in df.columns:
|