File size: 1,177 Bytes
890025a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st

def display_ai_insights():
    """Displays AI-Powered Insights and Data Cleaning Process."""
    
    st.header("💡 AI-Powered Insights")
    
    with st.expander("🧹 Data Cleaning Process", expanded=True):
        if "insights" in st.session_state and "df" in st.session_state:
            # Split insights into cleaning process and analysis
            parts = st.session_state.insights.split("ANALYSIS INSIGHTS:")
            
            # Show cleaning instructions
            st.markdown(parts[0])
            
            # Show interactive dataframe preview using st.session_state.df
            st.subheader("Cleaned Data Sample")
            st.dataframe(
                st.session_state.df.head(),  # Use the existing df state
                use_container_width=True,
                hide_index=True,
            )
            
            # Show analysis insights if present
            if len(parts) > 1:
                st.markdown("---")
                st.markdown("#### Analysis Insights")
                st.markdown(parts[1])
        else:
            st.warning("No insights generated yet. Upload and process a file first.")