Skip to content

Commit

Permalink
chore: fmt document
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovler-Young committed Dec 2, 2024
1 parent b331b5f commit 77452ef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ia_collection_analyzer/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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)

Expand Down

0 comments on commit 77452ef

Please sign in to comment.