Spaces:
Sleeping
Sleeping
poemsforaphrodite
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -463,14 +463,14 @@ def show_tabular_data(df, co):
|
|
463 |
return score
|
464 |
|
465 |
# Display column headers
|
466 |
-
cols = st.columns([3, 2, 1, 1, 1, 1, 1])
|
467 |
-
headers = ['Page', 'Query', 'Clicks', 'Impressions', 'CTR', 'Position', 'Relevancy Score']
|
468 |
for col, header in zip(cols, headers):
|
469 |
col.write(f"**{header}**")
|
470 |
|
471 |
# Display each row
|
472 |
for index, row in df_display.iterrows():
|
473 |
-
cols = st.columns([3, 2, 1, 1, 1, 1, 1])
|
474 |
cols[0].write(row['page'])
|
475 |
cols[1].write(row['query'])
|
476 |
cols[2].write(row['clicks'])
|
@@ -487,12 +487,31 @@ def show_tabular_data(df, co):
|
|
487 |
st.experimental_rerun()
|
488 |
else:
|
489 |
cols[6].write(f"{row['relevancy_score']:.4f}")
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
with st.
|
495 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
|
497 |
return df # Return the updated dataframe
|
498 |
|
|
|
463 |
return score
|
464 |
|
465 |
# Display column headers
|
466 |
+
cols = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
|
467 |
+
headers = ['Page', 'Query', 'Clicks', 'Impressions', 'CTR', 'Position', 'Relevancy Score', 'Competitors']
|
468 |
for col, header in zip(cols, headers):
|
469 |
col.write(f"**{header}**")
|
470 |
|
471 |
# Display each row
|
472 |
for index, row in df_display.iterrows():
|
473 |
+
cols = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
|
474 |
cols[0].write(row['page'])
|
475 |
cols[1].write(row['query'])
|
476 |
cols[2].write(row['clicks'])
|
|
|
487 |
st.experimental_rerun()
|
488 |
else:
|
489 |
cols[6].write(f"{row['relevancy_score']:.4f}")
|
490 |
+
|
491 |
+
# Competitors column
|
492 |
+
if cols[7].button("Show Competitors", key=f"comp_{index}"):
|
493 |
+
st.write(f"Competitor Analysis for: {row['query']}")
|
494 |
+
with st.spinner('Analyzing competitors...'):
|
495 |
+
results_df = analyze_competitors(row, co)
|
496 |
+
st.dataframe(results_df)
|
497 |
+
|
498 |
+
our_data = results_df[results_df['url'] == row['page']]
|
499 |
+
if not our_data.empty:
|
500 |
+
our_rank = our_data.index[0] + 1
|
501 |
+
total_results = len(results_df)
|
502 |
+
our_score = our_data['relevancy_score'].values[0]
|
503 |
+
|
504 |
+
st.write(f"Our page ranks {our_rank} out of {total_results} in terms of relevancy score.")
|
505 |
+
st.write(f"Our relevancy score: {our_score:.4f}")
|
506 |
+
|
507 |
+
if our_rank == 1:
|
508 |
+
st.success("Your page has the highest relevancy score!")
|
509 |
+
elif our_rank <= 3:
|
510 |
+
st.info("Your page is among the top 3 most relevant results.")
|
511 |
+
elif our_rank > total_results / 2:
|
512 |
+
st.warning("Your page's relevancy score is in the lower half of the results. Consider optimizing your content.")
|
513 |
+
else:
|
514 |
+
st.error(f"Our page '{row['page']}' is not in the results. This indicates an error in fetching or processing the page.")
|
515 |
|
516 |
return df # Return the updated dataframe
|
517 |
|