CCockrum commited on
Commit
da2bbef
Β·
verified Β·
1 Parent(s): 8dba0ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -14
app.py CHANGED
@@ -223,21 +223,25 @@ if fetch_data:
223
  return pd.isna(value) or value in ["", "N/A", "null", None]
224
 
225
  if not metadata_df.empty:
226
- # Incomplete record detection
227
- incomplete_mask = metadata_df.apply(lambda row: row.map(is_incomplete), axis=1).any(axis=1)
228
- incomplete_count = incomplete_mask.sum()
229
-
230
- # Overall completeness
231
- total_fields = metadata_df.size
232
- filled_fields = metadata_df.apply(lambda row: row.map(lambda x: not is_incomplete(x)), axis=1).sum().sum()
233
- overall_percent = (filled_fields / total_fields) * 100
234
-
235
- # Field-by-field completeness
236
- completeness = metadata_df.map(lambda x: not is_incomplete(x)).mean() * 100
237
- completeness_table = completeness.round(1).to_frame(name="Completeness (%)")
238
-
239
- # Render stats summary in sidebar
240
  stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
241
 
242
  # Render collapsible green completeness table in sidebar
243
  with st.sidebar.expander("πŸ“Š Field Completeness Breakdown", expanded=True):
 
223
  return pd.isna(value) or value in ["", "N/A", "null", None]
224
 
225
  if not metadata_df.empty:
226
+ ...
227
+ stats_html = f"""
228
+ <div class="sidebar-stats">
229
+ <h3 style="color: lightgray;">πŸ“Š Quick Stats</h3>
230
+ <p style="color:lightgray;">Total Records: <b>{len(metadata_df)}</b></p>
231
+ <p style="color:lightgray;">Incomplete Records: <b>{incomplete_count}</b></p>
232
+ <p style="color:lightgray;">Overall Metadata Completeness: <b>{overall_percent:.1f}%</b></p>
233
+ </div>
234
+ """
 
 
 
 
 
235
  stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
236
+
237
+ # βœ… Then show this right after
238
+ with st.sidebar.expander("πŸ“Š Field Completeness Breakdown", expanded=True):
239
+ st.dataframe(
240
+ completeness_table.style.background_gradient(cmap="Greens").format("{:.1f}%"),
241
+ use_container_width=True,
242
+ height=240
243
+ )
244
+
245
 
246
  # Render collapsible green completeness table in sidebar
247
  with st.sidebar.expander("πŸ“Š Field Completeness Breakdown", expanded=True):