Spaces:
Sleeping
Sleeping
Commit ·
3b875a3
1
Parent(s): ffdbe10
Fixed broken link
Browse files
app.py
CHANGED
|
@@ -174,7 +174,7 @@ with tab3:
|
|
| 174 |
# This message is now handled inside create_geolocation_map
|
| 175 |
pass
|
| 176 |
|
| 177 |
-
# --- Tab 4: Action Items ---
|
| 178 |
with tab4:
|
| 179 |
st.header("Posts & Comments That Need Attention")
|
| 180 |
st.write("A prioritized list of negative or inquiry-based comments mentioning Prime Bank.")
|
|
@@ -193,6 +193,8 @@ with tab4:
|
|
| 193 |
)
|
| 194 |
attention_df.sort_values(by='priority_score', ascending=False, inplace=True)
|
| 195 |
|
|
|
|
|
|
|
| 196 |
# Define columns to display initially
|
| 197 |
display_columns = ['text', 'sentiment', 'category', 'emotion', 'viral_score']
|
| 198 |
|
|
@@ -202,25 +204,24 @@ with tab4:
|
|
| 202 |
link_col = 'link'
|
| 203 |
elif 'url' in attention_df.columns:
|
| 204 |
link_col = 'url'
|
| 205 |
-
|
| 206 |
-
#
|
| 207 |
-
column_config = {}
|
| 208 |
if link_col:
|
| 209 |
-
#
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
column_config[link_col] = st.column_config.LinkColumn(
|
| 213 |
-
"Source Link",
|
| 214 |
-
display_text="Open Post ↗"
|
| 215 |
)
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
# Display the dataframe
|
| 218 |
st.dataframe(
|
| 219 |
attention_df[display_columns],
|
| 220 |
use_container_width=True,
|
| 221 |
-
|
| 222 |
-
hide_index=True # Hiding the index for a cleaner look
|
| 223 |
)
|
|
|
|
|
|
|
| 224 |
else:
|
| 225 |
st.success("✅ No negative comments or inquiries found that require attention.")
|
| 226 |
else:
|
|
|
|
| 174 |
# This message is now handled inside create_geolocation_map
|
| 175 |
pass
|
| 176 |
|
| 177 |
+
# --- Tab 4: Action Items (MODIFIED FOR RELIABLE LINKS) ---
|
| 178 |
with tab4:
|
| 179 |
st.header("Posts & Comments That Need Attention")
|
| 180 |
st.write("A prioritized list of negative or inquiry-based comments mentioning Prime Bank.")
|
|
|
|
| 193 |
)
|
| 194 |
attention_df.sort_values(by='priority_score', ascending=False, inplace=True)
|
| 195 |
|
| 196 |
+
# --- START: NEW, MORE RELIABLE LINK METHOD ---
|
| 197 |
+
|
| 198 |
# Define columns to display initially
|
| 199 |
display_columns = ['text', 'sentiment', 'category', 'emotion', 'viral_score']
|
| 200 |
|
|
|
|
| 204 |
link_col = 'link'
|
| 205 |
elif 'url' in attention_df.columns:
|
| 206 |
link_col = 'url'
|
| 207 |
+
|
| 208 |
+
# If a link column exists, create a new column with Markdown links
|
|
|
|
| 209 |
if link_col:
|
| 210 |
+
# Create a new column with the full Markdown string
|
| 211 |
+
attention_df['Source'] = attention_df[link_col].apply(
|
| 212 |
+
lambda url: f"[Open Post ↗]({url})" if pd.notna(url) else "No Link"
|
|
|
|
|
|
|
|
|
|
| 213 |
)
|
| 214 |
+
# Add the new 'Source' column to the front of our display list
|
| 215 |
+
display_columns.insert(1, 'Source')
|
| 216 |
|
| 217 |
+
# Display the dataframe. Streamlit will automatically render the Markdown.
|
| 218 |
st.dataframe(
|
| 219 |
attention_df[display_columns],
|
| 220 |
use_container_width=True,
|
| 221 |
+
hide_index=True
|
|
|
|
| 222 |
)
|
| 223 |
+
# --- END: NEW, MORE RELIABLE LINK METHOD ---
|
| 224 |
+
|
| 225 |
else:
|
| 226 |
st.success("✅ No negative comments or inquiries found that require attention.")
|
| 227 |
else:
|