CCockrum commited on
Commit
e9e9f4c
Β·
verified Β·
1 Parent(s): 9e7da33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -8
app.py CHANGED
@@ -83,10 +83,12 @@ st.markdown("""
83
  font-weight: 600;
84
  }
85
  .sidebar-contrast-block {
86
- background-color: #2b2b2b !important; /* Slightly lighter than #1A1A1A */
87
  padding: 1.25rem;
88
  border-radius: 10px;
89
  margin-top: 1.5rem;
 
 
90
  }
91
 
92
  </style>
@@ -222,30 +224,55 @@ if fetch_data:
222
  def is_incomplete(value):
223
  return pd.isna(value) or value in ["", "N/A", "null", None]
224
 
 
225
  if not metadata_df.empty:
226
  incomplete_mask = metadata_df.map(is_incomplete).any(axis=1)
227
  incomplete_count = incomplete_mask.sum()
228
  total_fields = metadata_df.size
229
  filled_fields = (~metadata_df.map(is_incomplete)).sum().sum()
230
  overall_percent = (filled_fields / total_fields) * 100
231
-
 
 
 
 
 
 
232
  stats_html = f"""
233
- <div class="sidebar-stats">
234
- <h3 style="color: lightgray;">πŸ“Š Quick Stats</h3>
235
  <p style="color:lightgray;">Total Records: <b>{len(metadata_df)}</b></p>
236
  <p style="color:lightgray;">Incomplete Records: <b>{incomplete_count}</b></p>
237
- <p style="color:lightgray;">Overall Metadata Completeness: <b>{overall_percent:.1f}%</b></p>
238
  </div>
239
  """
240
  stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
241
-
242
- # βœ… Then show this right after
243
- with st.sidebar.expander("πŸ“Š Field Completeness Breakdown", expanded=True):
244
  st.dataframe(
245
  completeness_table.style.background_gradient(cmap="Greens").format("{:.1f}%"),
246
  use_container_width=True,
247
  height=240
248
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
 
251
  # Render collapsible green completeness table in sidebar
 
83
  font-weight: 600;
84
  }
85
  .sidebar-contrast-block {
86
+ background-color: #2b2b2b !important;
87
  padding: 1.25rem;
88
  border-radius: 10px;
89
  margin-top: 1.5rem;
90
+ }
91
+
92
  }
93
 
94
  </style>
 
224
  def is_incomplete(value):
225
  return pd.isna(value) or value in ["", "N/A", "null", None]
226
 
227
+
228
  if not metadata_df.empty:
229
  incomplete_mask = metadata_df.map(is_incomplete).any(axis=1)
230
  incomplete_count = incomplete_mask.sum()
231
  total_fields = metadata_df.size
232
  filled_fields = (~metadata_df.map(is_incomplete)).sum().sum()
233
  overall_percent = (filled_fields / total_fields) * 100
234
+
235
+ # Field-level completeness
236
+ completeness = (~metadata_df.map(is_incomplete)).mean() * 100
237
+ completeness_df = pd.DataFrame({"Field": completeness.index, "Completeness (%)": completeness.values})
238
+ completeness_table = completeness_df.set_index("Field")
239
+
240
+ # πŸ“Š Sidebar Quick Stats
241
  stats_html = f"""
242
+ <div class="sidebar-contrast-block">
243
+ <h4 style="color: lightgray;">πŸ“Š Quick Stats</h4>
244
  <p style="color:lightgray;">Total Records: <b>{len(metadata_df)}</b></p>
245
  <p style="color:lightgray;">Incomplete Records: <b>{incomplete_count}</b></p>
246
+ <p style="color:lightgray;">Overall Completeness: <b>{overall_percent:.1f}%</b></p>
247
  </div>
248
  """
249
  stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
250
+
251
+ # πŸ“Š Field Completeness Breakdown (modern expander)
252
+ with st.sidebar.expander("πŸ“‹ Field Completeness Breakdown", expanded=True):
253
  st.dataframe(
254
  completeness_table.style.background_gradient(cmap="Greens").format("{:.1f}%"),
255
  use_container_width=True,
256
  height=240
257
  )
258
+
259
+ # ------------------- Helpful Resources -------------------
260
+ st.sidebar.markdown("""
261
+ <div class="sidebar-section">
262
+ <h3>πŸ”— Helpful Resources</h3>
263
+ <div class="sidebar-links">
264
+ <ul style='padding-left: 1em'>
265
+ <li><a href="https://www.loc.gov/apis/" target="_blank">LOC API Info</a></li>
266
+ <li><a href="https://www.loc.gov/" target="_blank">Library of Congress Homepage</a></li>
267
+ <li><a href="https://www.loc.gov/collections/" target="_blank">LOC Digital Collections</a></li>
268
+ <li><a href="https://www.loc.gov/marc/" target="_blank">MARC Metadata Standards</a></li>
269
+ <li><a href="https://labs.loc.gov/about-labs/digital-strategy/" target="_blank">LOC Digital Strategy</a></li>
270
+ </ul>
271
+ </div>
272
+ </div>
273
+ """, unsafe_allow_html=True)
274
+
275
+
276
 
277
 
278
  # Render collapsible green completeness table in sidebar