os1187 commited on
Commit
c40f5aa
·
verified ·
1 Parent(s): 5b98dcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -62,18 +62,14 @@ col1, col2 = st.columns([1, 3])
62
 
63
  with col1:
64
  st.subheader("Stock Overview")
65
- # Adjust styling approach here
 
 
66
  def color_combined_score(value):
67
- """Colors the combined score cell based on its value."""
68
- if value > 0:
69
- color = 'green'
70
- elif value < 0:
71
- color = 'red'
72
- else:
73
- color = 'none'
74
  return f'background-color: {color};'
75
 
76
- # Apply the styling function to the 'Combined Score' column only
77
  styled_scores_df = scores_df_sorted.style.applymap(color_combined_score, subset=['Combined Score'])
78
  st.dataframe(styled_scores_df)
79
 
@@ -85,15 +81,12 @@ with col2:
85
  stock_data, info = fetch_stock_data(ticker_symbol)
86
  comparison, _ = compare_to_index(stock_data, sp500_averages)
87
 
88
- # Display the company name and its ticker symbol
89
- st.markdown(f"**{info.get('longName', 'N/A')}** ({ticker_symbol})")
90
-
91
- # Display the company's business summary
92
- st.write(info.get('longBusinessSummary', 'Description not available.'))
93
 
94
  # Display each financial ratio and its comparison result
95
  for ratio, status in comparison.items():
96
- st.text(f"{ratio}: {status}")
97
-
98
 
99
 
 
62
 
63
  with col1:
64
  st.subheader("Stock Overview")
65
+ # Make sure to convert 'Combined Score' to numeric if it's not already
66
+ scores_df_sorted['Combined Score'] = pd.to_numeric(scores_df_sorted['Combined Score'], errors='coerce')
67
+ # Apply color based on 'Combined Score' value
68
  def color_combined_score(value):
69
+ color = 'green' if value > 0 else 'red' if value < 0 else 'none'
 
 
 
 
 
 
70
  return f'background-color: {color};'
71
 
72
+ # Use 'Styler' to apply the style function to the 'Combined Score' column
73
  styled_scores_df = scores_df_sorted.style.applymap(color_combined_score, subset=['Combined Score'])
74
  st.dataframe(styled_scores_df)
75
 
 
81
  stock_data, info = fetch_stock_data(ticker_symbol)
82
  comparison, _ = compare_to_index(stock_data, sp500_averages)
83
 
84
+ # Display the company name and ticker symbol
85
+ st.write(f"**{info.get('longName')}** ({ticker_symbol})")
86
+ st.write(info.get('longBusinessSummary'))
 
 
87
 
88
  # Display each financial ratio and its comparison result
89
  for ratio, status in comparison.items():
90
+ st.write(f"{ratio}: {status}")
 
91
 
92