File size: 3,491 Bytes
9c761b8
 
c4f9397
 
9c761b8
c4f9397
 
9c761b8
29d1685
 
9c761b8
 
29d1685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4f9397
29d1685
 
c4f9397
 
 
 
29d1685
c4f9397
 
29d1685
 
c4f9397
 
29d1685
 
9c761b8
29d1685
c4f9397
29d1685
c4f9397
 
29d1685
9c761b8
29d1685
 
c4f9397
29d1685
 
9c761b8
c4f9397
 
29d1685
c4f9397
29d1685
 
 
 
54cdf72
29d1685
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c761b8
bc48345
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Configure the Streamlit app
st.title("Exploratory Data Analysis (EDA) App")
st.markdown("""
By performing simple Exploratory Data Analysis (EDA), we can examine the data, identify patterns, and detect anomalies or inconsistencies. This process allows us to clean and preprocess the dataset effectively, ensuring it is well-structured and ready for further analysis or modeling. Simple EDA helps uncover hidden insights, address missing or erroneous values, and optimize the data for better decision-making.

""")

# File uploader for dataset
uploaded_file = st.file_uploader("Upload your dataset (CSV format):", type=["csv"])

if uploaded_file is not None:
    # Read and display the dataset
    data = pd.read_csv(uploaded_file)
    st.write("### Uploaded Dataset:")
    st.dataframe(data)

    # Overview of the dataset
    st.write("### Dataset Overview:")
    st.write(data.describe())

    # Missing values in the dataset
    st.write("### Missing Values:")
    st.write(data.isnull().sum())

    # Duplicate rows in the dataset
    st.write("### Duplicate Rows:")
    st.write(f"Number of duplicate rows: {data.duplicated().sum()}")

    # Visualizations for numeric columns
    st.write("### Numeric Column Visualizations:")
    st.write("Histograms:")
    fig, ax = plt.subplots()
    data.hist(ax=ax, figsize=(10, 8))
    st.pyplot(fig)

    st.write("Boxplot:")
    fig, ax = plt.subplots()
    sns.boxplot(data=data, orient='h', ax=ax)
    st.pyplot(fig)

    # Value counts and bar plot for categorical data
    categorical_columns = data.select_dtypes(include=['object', 'category']).columns
    if len(categorical_columns) > 0:
        selected_cat_col = st.selectbox("Select a Categorical Column to Analyze", categorical_columns)
        st.write(f"Value Counts for '{selected_cat_col}':")
        st.write(data[selected_cat_col].value_counts())

        st.write(f"Bar Plot for '{selected_cat_col}':")
        fig, ax = plt.subplots()
        sns.countplot(x=selected_cat_col, data=data, ax=ax)
        st.pyplot(fig)
    else:
        st.write("No categorical columns available for analysis.")

    # Correlation matrix
    numeric_columns = data.select_dtypes(include=['float64', 'int64']).columns
    if len(numeric_columns) > 1:
        st.write("### Correlation Matrix:")
        st.write(data[numeric_columns].corr())

        st.write("Heatmap of Correlation Matrix:")
        fig, ax = plt.subplots()
        sns.heatmap(data[numeric_columns].corr(), annot=True, cmap='coolwarm', ax=ax)
        st.pyplot(fig)

    # Clean the data: Handle missing values and duplicates
    st.write("### Cleaned Dataset:")
    cleaned_data = data.drop_duplicates()  # Remove duplicate rows
    #cleaned_data = cleaned_data.fillna(cleaned_data.mean())  # Replace missing values with the mean for numeric columns
    st.dataframe(cleaned_data)

    # Download button for the cleaned dataset
    cleaned_csv = cleaned_data.to_csv(index=False).encode('utf-8')
    st.download_button(
        label="Download Cleaned Dataset",
        data=cleaned_csv,
        file_name="cleaned_dataset.csv",
        mime="text/csv"
    )

    st.markdown("""
    This analysis provides a basic understanding of the dataset. 
    You can now download the cleaned dataset and proceed with further analysis or modeling.
    """)
else:
    st.warning("Please upload a dataset to proceed with Simple EDA.")