File size: 4,675 Bytes
2a6b09f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import pandas as pd
import streamlit as st
import plotly.express as px

# Classy and centered title
st.markdown(
    """

    <h1 style="text-align: center; color: skyblue;"> Tips Dataset Dashboard</h1>

    """,
    unsafe_allow_html=True
)

# File Upload
file = st.file_uploader("๐Ÿ“ Upload a CSV file", type=["csv"])

if file is not None:
    df = pd.read_csv(file)
    
    st.markdown("### ๐Ÿ” Preview of Data")
    st.write(df.head())

    # Separate Numerical and Categorical Columns
    num = df.select_dtypes('number')
    cat = df.select_dtypes('object')
    numerical = num.columns.tolist()
    categorical = cat.columns.tolist()

    st.markdown("### ๐ŸŸจ Categorical Features")
    st.write(cat)

    st.markdown("### ๐ŸŸฆ Numerical Features")
    st.write(num)

    # ๐Ÿ“Š Categorical Feature Analysis
    st.markdown("## ๐Ÿ“‹ Categorical Feature Analysis")
    for col in categorical:
        st.write(f"### ๐Ÿ”ธ Feature: `{col}`")
        st.write("๐Ÿ”ข Value Counts:")
        st.write(df[col].value_counts())
        st.write("๐Ÿ“œ Unique Values:")
        st.write(df[col].unique())
        st.write("๐Ÿงฎ Number of Unique Values:", df[col].nunique())
        st.write("โ“ Missing Values:", df[col].isnull().sum())
        st.markdown("---")

    # ๐Ÿ“ˆ Numerical Feature Analysis
    st.markdown("## ๐Ÿ“Š Numerical Feature Analysis")
    for col in numerical:
        st.write(f"### ๐Ÿ”น Feature: `{col}`")
        st.write("๐Ÿ“ Mean:", df[col].mean())
        st.write("๐Ÿช™ Median:", df[col].median())
        st.write("๐Ÿ“‰ Std Deviation:", df[col].std())
        st.write("๐Ÿ“ Variance:", df[col].var())
        st.write("๐Ÿ“ˆ Skewness:", df[col].skew())
        st.write("๐Ÿ”บ Kurtosis:", df[col].kurt())
        st.write("๐Ÿ”ฝ Minimum:", df[col].min())
        st.write("๐Ÿ”ผ Maximum:", df[col].max())
        st.write("โ“ Missing Values:", df[col].isnull().sum())
        st.markdown("---")

    # ๐Ÿ”— Bivariate Analysis
    st.markdown("## ๐Ÿ”— Bivariate Analysis")

    # Scatter Plot
    st.markdown("### ๐Ÿ“ Scatter Plot")
    num_x = st.selectbox('๐Ÿงญ Select X-axis (Numerical)', numerical, key='scatter_x')
    num_y = st.selectbox('๐Ÿ“Œ Select Y-axis (Numerical)', numerical, key='scatter_y')
    if num_x and num_y:
        st.write(f"๐Ÿ”Ž Scatter plot between `{num_x}` and `{num_y}`")
        fig = px.scatter(df, x=num_x, y=num_y, title=f'Scatter plot: {num_x} vs {num_y}')
        st.plotly_chart(fig)

    # Box Plot
    st.markdown("### ๐ŸŽ Box Plot")
    cat_feature = st.selectbox('๐ŸงŠ Select Category', categorical, key='box_cat')
    num_feature = st.selectbox('๐Ÿ“ Select Value (Numerical)', numerical, key='box_num')
    if cat_feature and num_feature:
        fig = px.box(df, x=cat_feature, y=num_feature, title=f'Box plot of {num_feature} by {cat_feature}')
        st.plotly_chart(fig)

    # Correlation Matrix
    st.markdown("### ๐Ÿ”ฅ Correlation Matrix")
    corr = num.corr()
    fig = px.imshow(corr, text_auto=True, title='Correlation Heatmap')
    st.plotly_chart(fig)

    # Pairplot
    st.markdown("### ๐ŸŒ Pairplot")
    if len(numerical) > 1:
        fig = px.scatter_matrix(df, dimensions=numerical, title='Pairplot of Numerical Features')
        st.plotly_chart(fig)

    # Count Plot
    st.markdown("### ๐Ÿ“Š Count Plot")
    cat_feature_count = st.selectbox('๐Ÿ“‹ Select a categorical feature', categorical, key='count_plot')
    if cat_feature_count:
        value_counts_df = df[cat_feature_count].value_counts().reset_index()
        value_counts_df.columns = [cat_feature_count, 'Count']
        fig = px.bar(value_counts_df, x=cat_feature_count, y='Count',
                     title=f'Count Plot for {cat_feature_count}',
                     labels={cat_feature_count: cat_feature_count, 'Count': 'Count'})
        st.plotly_chart(fig)

    # Distribution Plot
    st.markdown("### ๐Ÿงฎ Distribution Plot")
    num_feature_dist = st.selectbox('๐Ÿ”ข Select a numerical feature', numerical, key='dist_plot')
    if num_feature_dist:
        fig = px.histogram(df, x=num_feature_dist, nbins=30,
                           title=f'Distribution of {num_feature_dist}')
        st.plotly_chart(fig)

    # Pie Chart
    st.markdown("### ๐Ÿฅง Pie Chart")
    cat_feature_pie = st.selectbox('๐Ÿง  Select categorical feature for pie chart', categorical, key='pie_chart')
    if cat_feature_pie:
        fig = px.pie(df, names=cat_feature_pie, title=f'Pie Chart of {cat_feature_pie}')
        st.plotly_chart(fig)

else:
    st.warning("๐Ÿ“ Please upload a CSV file to begin.")