CosmickVisions commited on
Commit
c20d507
ยท
verified ยท
1 Parent(s): 5dfa301

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -48
app.py CHANGED
@@ -25,7 +25,8 @@ from stqdm import stqdm
25
  def enhance_section_title(title, icon="โœจ"):
26
  """Helper function to create a styled section title with an icon."""
27
  st.markdown(f"<h2 style='border-bottom: 2px solid #ccc; padding-bottom: 5px;'>{icon} {title}</h2>", unsafe_allow_html=True)
28
-
 
29
  def update_cleaned_data(df):
30
  """Updates the cleaned data in session state."""
31
  st.session_state.cleaned_data = df
@@ -330,43 +331,6 @@ with st.sidebar:
330
  if app_mode == "Data Upload":
331
  st.title("๐Ÿ“ค Data Upload & Profiling")
332
 
333
- uploaded_file = st.file_uploader("Upload your dataset (CSV/XLSX)", type=["csv", "xlsx"])
334
-
335
- if uploaded_file:
336
- try:
337
- if uploaded_file.name.endswith('.csv'):
338
- df = pd.read_csv(uploaded_file)
339
- else:
340
- df = pd.read_excel(uploaded_file)
341
-
342
- st.session_state.raw_data = df
343
-
344
- col1, col2, col3 = st.columns(3)
345
- with col1:
346
- st.metric("Rows", df.shape[0])
347
- with col2:
348
- st.metric("Columns", df.shape[1])
349
- with col3:
350
- st.metric("Missing Values", df.isna().sum().sum())
351
-
352
- with st.expander("Data Preview", expanded=True):
353
- st.dataframe(df.head(10), use_container_width=True)
354
-
355
- if st.button("Generate Full Profile Report"):
356
- with st.spinner("Generating comprehensive analysis..."):
357
- pr = ProfileReport(df, explorative=True)
358
- st_profile_report(pr)
359
-
360
- except Exception as e:
361
- st.error(f"Error loading file: {str(e)}")
362
-
363
- # --------------------------
364
- # Page Content
365
- # --------------------------
366
- # Data Upload Section
367
- if app_mode == "Data Upload":
368
- st.title("๐Ÿ“ค Data Upload & Profiling")
369
-
370
  uploaded_file = st.file_uploader("Upload your dataset (CSV/XLSX)", type=["csv", "xlsx"], key="file_uploader")
371
 
372
  if uploaded_file:
@@ -413,10 +377,8 @@ elif app_mode == "Data Cleaning":
413
  st.warning("No cleaned data available. Please clean your data first.")
414
  st.stop() # Stop execution if no cleaned data is available
415
 
416
-
417
  # Data Health Dashboard
418
  enhance_section_title("Data Health Dashboard", "๐Ÿ“Š")
419
-
420
  with st.expander("๐Ÿ“Š Data Health Dashboard", expanded=True):
421
  col1, col2, col3 = st.columns(3)
422
  with col1:
@@ -432,14 +394,6 @@ elif app_mode == "Data Cleaning":
432
  profile = ProfileReport(df, minimal=True)
433
  st_profile_report(profile)
434
 
435
- # Undo Functionality
436
- if len(st.session_state.data_versions) > 1:
437
- if st.button("โฎ๏ธ Undo Last Action"):
438
- st.session_state.data_versions.pop() # Remove current version
439
- st.session_state.cleaned_data = st.session_state.data_versions[-1].copy() # Set data
440
- st.success("Last action undone!")
441
- st.experimental_rerun() # Force re-run after undo
442
-
443
  # Missing Value Handling
444
  enhance_section_title("Missing Values Treatment", "๐Ÿ”")
445
  with st.expander("๐Ÿ” Missing Values Treatment", expanded=True):
 
25
  def enhance_section_title(title, icon="โœจ"):
26
  """Helper function to create a styled section title with an icon."""
27
  st.markdown(f"<h2 style='border-bottom: 2px solid #ccc; padding-bottom: 5px;'>{icon} {title}</h2>", unsafe_allow_html=True)
28
+
29
+ @st.cache_data
30
  def update_cleaned_data(df):
31
  """Updates the cleaned data in session state."""
32
  st.session_state.cleaned_data = df
 
331
  if app_mode == "Data Upload":
332
  st.title("๐Ÿ“ค Data Upload & Profiling")
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  uploaded_file = st.file_uploader("Upload your dataset (CSV/XLSX)", type=["csv", "xlsx"], key="file_uploader")
335
 
336
  if uploaded_file:
 
377
  st.warning("No cleaned data available. Please clean your data first.")
378
  st.stop() # Stop execution if no cleaned data is available
379
 
 
380
  # Data Health Dashboard
381
  enhance_section_title("Data Health Dashboard", "๐Ÿ“Š")
 
382
  with st.expander("๐Ÿ“Š Data Health Dashboard", expanded=True):
383
  col1, col2, col3 = st.columns(3)
384
  with col1:
 
394
  profile = ProfileReport(df, minimal=True)
395
  st_profile_report(profile)
396
 
 
 
 
 
 
 
 
 
397
  # Missing Value Handling
398
  enhance_section_title("Missing Values Treatment", "๐Ÿ”")
399
  with st.expander("๐Ÿ” Missing Values Treatment", expanded=True):