James McCool
commited on
Commit
·
1dd4cb9
1
Parent(s):
b6cb507
Add portfolio parsing function with mapping and filtering capabilities
Browse files
app.py
CHANGED
|
@@ -1023,6 +1023,20 @@ def create_position_export_dict(column_name, csv_file, site_var, type_var, sport
|
|
| 1023 |
st.error(f"Error creating position export dict for {column_name}: {str(e)}")
|
| 1024 |
return {}
|
| 1025 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1026 |
with st.container():
|
| 1027 |
|
| 1028 |
col1, col2, col3, col4 = st.columns([1, 4, 4, 4])
|
|
|
|
| 1023 |
st.error(f"Error creating position export dict for {column_name}: {str(e)}")
|
| 1024 |
return {}
|
| 1025 |
|
| 1026 |
+
def parse_portfolio_on_mapped(portfolio, map_dict, map_key, filter_keys, low_threshold, high_threshold, column_choices):
|
| 1027 |
+
mapping_port = portfolio[column_choices].map(map_dict[map_key])
|
| 1028 |
+
|
| 1029 |
+
if map_key not in ['team_map', 'pos_map']:
|
| 1030 |
+
# Numerical mapping - filter by thresholds
|
| 1031 |
+
low_mask = mapping_port > low_threshold
|
| 1032 |
+
high_mask = mapping_port < high_threshold
|
| 1033 |
+
mask = low_mask & high_mask
|
| 1034 |
+
else:
|
| 1035 |
+
# String mapping - filter by inclusion in filter_keys
|
| 1036 |
+
mask = mapping_port.isin(filter_keys)
|
| 1037 |
+
|
| 1038 |
+
return portfolio[mask]
|
| 1039 |
+
|
| 1040 |
with st.container():
|
| 1041 |
|
| 1042 |
col1, col2, col3, col4 = st.columns([1, 4, 4, 4])
|