James McCool
Refactor import statements across multiple files to replace 'fuzzywuzzy' with 'rapidfuzz' for improved performance and consistency in string matching functionality. Additionally, clean up unused imports in app.py and related global functions to enhance code clarity and maintainability.
d9db89f
import streamlit as st | |
import numpy as np | |
import pandas as pd | |
import time | |
from rapidfuzz import process | |
def highlight_changes(row): | |
original_row = st.session_state['portfolio'].iloc[row.name] | |
colors = [''] * len(row) | |
for i, (orig, new) in enumerate(zip(original_row, row)): | |
if orig != new: | |
colors[i] = 'background-color: yellow' | |
return colors | |
def highlight_changes_winners(row): | |
original_row = st.session_state['optimized_df_medians'].iloc[row.name] | |
colors = [''] * len(row) | |
for i, (orig, new) in enumerate(zip(original_row, row)): | |
if orig != new: | |
colors[i] = 'background-color: aqua' | |
return colors | |
def highlight_changes_losers(row): | |
original_row = st.session_state['optimized_df_winners'].iloc[row.name] | |
colors = [''] * len(row) | |
for i, (orig, new) in enumerate(zip(original_row, row)): | |
if orig != new: | |
colors[i] = 'background-color: darksalmon' | |
return colors |