From 77452efaf40fd621c3c9da7f0eaafd1b21946627 Mon Sep 17 00:00:00 2001 From: Ovler Date: Mon, 2 Dec 2024 03:44:35 -0500 Subject: [PATCH] chore: fmt document --- src/ia_collection_analyzer/streamlit.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ia_collection_analyzer/streamlit.py b/src/ia_collection_analyzer/streamlit.py index b500e141..21e2c85b 100644 --- a/src/ia_collection_analyzer/streamlit.py +++ b/src/ia_collection_analyzer/streamlit.py @@ -377,13 +377,13 @@ def safe_map(x): str_val = str(x) # Convert full list to string for matching if str_val in mapping_dict: return mapping_dict[str_val] - + # Try mapping individual elements mapped = [mapping_dict.get(item, item) for item in x] return mapped else: return mapping_dict.get(x, x) - + # Create mapping dictionary mapping_dict = {} for m in st.session_state.mapping_table: @@ -396,13 +396,13 @@ def safe_map(x): mapping_dict[eval(source)] = m["target"] except: pass - + # Apply mapping with list handling new_col = filtered_pd[source_col].map(safe_map) # Show preview preview_rows = [] - + # Get samples for each mapping for mapping in st.session_state.mapping_table: # For each source value in the mapping @@ -422,7 +422,7 @@ def safe_map(x): ) if not unmatched.empty: preview_rows.append(unmatched) - + # Combine samples preview_df = pd.concat(preview_rows) preview_df = pd.DataFrame( @@ -431,7 +431,7 @@ def safe_map(x): "Transformed": preview_df[source_col].map(safe_map), } ) - + st.write("Preview showing examples of each mapping:") st.write(preview_df.T)