trohith89 commited on
Commit
9f93e54
·
verified ·
1 Parent(s): 7d15fee

Update pages/2_Data_CLeaning_and_Preprocessing.py

Browse files
pages/2_Data_CLeaning_and_Preprocessing.py CHANGED
@@ -1,11 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import os
4
- from io import StringIO
5
- import sys
6
- import plotly.graph_objects as go
7
- import plotly.express as px
8
- from plotly.subplots import make_subplots
9
  from io import StringIO
10
 
11
  # Page Title
@@ -36,22 +32,20 @@ if df is not None:
36
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
37
  if len(numeric_columns) > 0:
38
  st.subheader("Histograms for Numeric Columns:")
39
- fig = make_subplots(rows=len(numeric_columns), cols=1, subplot_titles=numeric_columns)
40
- for i, col in enumerate(numeric_columns):
41
- hist = px.histogram(df, x=col, nbins=30, title=f'Histogram of {col}')
42
- fig.add_trace(hist.data[0], row=i + 1, col=1)
43
-
44
- fig.update_layout(height=500 * len(numeric_columns), title_text="Histograms for Numeric Columns")
45
- st.plotly_chart(fig)
46
 
47
  st.subheader("Boxplots for Numeric Columns:")
48
- fig = make_subplots(rows=len(numeric_columns), cols=1, subplot_titles=numeric_columns)
49
- for i, col in enumerate(numeric_columns):
50
- boxplot = px.box(df, y=col, title=f'Boxplot of {col}')
51
- fig.add_trace(boxplot.data[0], row=i + 1, col=1)
52
-
53
- fig.update_layout(height=500 * len(numeric_columns), title_text="Boxplots for Numeric Columns")
54
- st.plotly_chart(fig)
55
  else:
56
  st.warning("No numeric columns available for visualization.")
57
 
@@ -64,18 +58,14 @@ if df is not None:
64
  st.write(f"Value Counts for '{selected_cat_col}':")
65
  st.write(df[selected_cat_col].value_counts())
66
 
67
- fig = px.bar(df, x=selected_cat_col, title=f'Bar Plot of {selected_cat_col}', color=selected_cat_col)
68
- st.plotly_chart(fig)
 
 
 
69
  else:
70
  st.warning("No categorical columns available for visualization.")
71
 
72
- # Correlation Matrix for Numeric Columns
73
- if len(numeric_columns) > 1:
74
- st.subheader("Correlation Matrix:")
75
- corr_matrix = df[numeric_columns].corr()
76
- fig = px.imshow(corr_matrix, title="Correlation Matrix", color_continuous_scale='coolwarm')
77
- st.plotly_chart(fig)
78
-
79
  st.subheader("Cleaned Dataset:")
80
  cleaned_data = df.drop_duplicates()
81
  st.write(cleaned_data)
@@ -120,7 +110,7 @@ st.markdown(
120
  /* Styling the content to ensure text visibility */
121
  .stMarkdown {{
122
  color: white; /* White text to ensure visibility */
123
- font-size: 100px; /* Adjust font size for better readability */
124
  }}
125
  </style>
126
  """,
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
 
 
 
 
5
  from io import StringIO
6
 
7
  # Page Title
 
32
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
33
  if len(numeric_columns) > 0:
34
  st.subheader("Histograms for Numeric Columns:")
35
+ for col in numeric_columns:
36
+ plt.figure(figsize=(10, 5))
37
+ sns.histplot(df[col], bins=30, kde=True)
38
+ plt.title(f'Histogram of {col}')
39
+ st.pyplot(plt)
40
+ plt.clf()
 
41
 
42
  st.subheader("Boxplots for Numeric Columns:")
43
+ for col in numeric_columns:
44
+ plt.figure(figsize=(10, 5))
45
+ sns.boxplot(x=df[col])
46
+ plt.title(f'Boxplot of {col}')
47
+ st.pyplot(plt)
48
+ plt.clf()
 
49
  else:
50
  st.warning("No numeric columns available for visualization.")
51
 
 
58
  st.write(f"Value Counts for '{selected_cat_col}':")
59
  st.write(df[selected_cat_col].value_counts())
60
 
61
+ plt.figure(figsize=(10, 5))
62
+ sns.countplot(x=selected_cat_col, data=df)
63
+ plt.title(f'Bar Plot of {selected_cat_col}')
64
+ st.pyplot(plt)
65
+ plt.clf()
66
  else:
67
  st.warning("No categorical columns available for visualization.")
68
 
 
 
 
 
 
 
 
69
  st.subheader("Cleaned Dataset:")
70
  cleaned_data = df.drop_duplicates()
71
  st.write(cleaned_data)
 
110
  /* Styling the content to ensure text visibility */
111
  .stMarkdown {{
112
  color: white; /* White text to ensure visibility */
113
+ font-size: 30px; /* Adjust font size for better readability */
114
  }}
115
  </style>
116
  """,