Spaces:
Sleeping
Sleeping
poemsforaphrodite
commited on
Commit
•
fde6668
1
Parent(s):
82b97bd
Update app.py
Browse files
app.py
CHANGED
@@ -298,6 +298,10 @@ def show_paginated_dataframe(report, rows_per_page=20):
|
|
298 |
# Convert 'position' column to integer
|
299 |
report['position'] = report['position'].astype(int)
|
300 |
|
|
|
|
|
|
|
|
|
301 |
# Create a clickable URL column
|
302 |
def make_clickable(url):
|
303 |
return f'<a href="{url}" target="_blank">{url}</a>'
|
@@ -309,11 +313,20 @@ def show_paginated_dataframe(report, rows_per_page=20):
|
|
309 |
report = report[columns]
|
310 |
|
311 |
# Add sorting functionality
|
312 |
-
sort_column = st.selectbox("Sort by:", columns[1:]) #
|
313 |
sort_order = st.radio("Sort order:", ("Descending", "Ascending"))
|
314 |
|
315 |
ascending = sort_order == "Ascending"
|
|
|
|
|
|
|
|
|
|
|
316 |
report = report.sort_values(by=sort_column, ascending=ascending)
|
|
|
|
|
|
|
|
|
317 |
|
318 |
total_rows = len(report)
|
319 |
total_pages = (total_rows - 1) // rows_per_page + 1
|
|
|
298 |
# Convert 'position' column to integer
|
299 |
report['position'] = report['position'].astype(int)
|
300 |
|
301 |
+
# Format CTR as percentage and relevancy_score with two decimal places
|
302 |
+
report['ctr'] = report['ctr'].apply(lambda x: f"{x:.2%}")
|
303 |
+
report['relevancy_score'] = report['relevancy_score'].apply(lambda x: f"{x:.2f}")
|
304 |
+
|
305 |
# Create a clickable URL column
|
306 |
def make_clickable(url):
|
307 |
return f'<a href="{url}" target="_blank">{url}</a>'
|
|
|
313 |
report = report[columns]
|
314 |
|
315 |
# Add sorting functionality
|
316 |
+
sort_column = st.selectbox("Sort by:", columns[1:], index=columns[1:].index('impressions')) # Set 'impressions' as default
|
317 |
sort_order = st.radio("Sort order:", ("Descending", "Ascending"))
|
318 |
|
319 |
ascending = sort_order == "Ascending"
|
320 |
+
|
321 |
+
# Convert back to numeric for sorting
|
322 |
+
report['ctr'] = report['ctr'].str.rstrip('%').astype('float') / 100
|
323 |
+
report['relevancy_score'] = report['relevancy_score'].astype('float')
|
324 |
+
|
325 |
report = report.sort_values(by=sort_column, ascending=ascending)
|
326 |
+
|
327 |
+
# Convert back to formatted strings for display
|
328 |
+
report['ctr'] = report['ctr'].apply(lambda x: f"{x:.2%}")
|
329 |
+
report['relevancy_score'] = report['relevancy_score'].apply(lambda x: f"{x:.2f}")
|
330 |
|
331 |
total_rows = len(report)
|
332 |
total_pages = (total_rows - 1) // rows_per_page + 1
|