trohith89 commited on
Commit
dd13c9f
·
verified ·
1 Parent(s): 17a9f3c

Update pages/2_Data_CLeaning_and_Preprocessing.py

Browse files
pages/2_Data_CLeaning_and_Preprocessing.py CHANGED
@@ -35,8 +35,11 @@ if df is not None:
35
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
36
  if len(numeric_columns) > 0:
37
  st.subheader("Histograms for Numeric Columns:")
38
- # Create a subplot for all histograms
39
- fig, axs = plt.subplots(len(numeric_columns), 1, figsize=(10, 5 * len(numeric_columns)))
 
 
 
40
 
41
  color_palettes_hist = ['Set1', 'Set2', 'Set3', 'Paired', 'Pastel1'] # Different color palettes for histograms
42
  for i, col in enumerate(numeric_columns):
@@ -47,8 +50,9 @@ if df is not None:
47
  plt.clf()
48
 
49
  st.subheader("Boxplots for Numeric Columns:")
50
- # Create a subplot for all boxplots
51
- fig, axs = plt.subplots(len(numeric_columns), 1, figsize=(10, 5 * len(numeric_columns)))
 
52
 
53
  color_palettes_box = ['coolwarm', 'Blues', 'viridis', 'cubehelix', 'crest'] # Different color palettes for boxplots
54
  for i, col in enumerate(numeric_columns):
@@ -69,7 +73,7 @@ if df is not None:
69
  st.write(f"Value Counts for '{selected_cat_col}':")
70
  st.write(df[selected_cat_col].value_counts())
71
 
72
- plt.figure(figsize=(10, 5))
73
  sns.countplot(x=selected_cat_col, data=df, palette='coolwarm') # Unique palette for categorical data
74
  plt.title(f'Bar Plot of {selected_cat_col}')
75
  st.pyplot(plt)
 
35
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
36
  if len(numeric_columns) > 0:
37
  st.subheader("Histograms for Numeric Columns:")
38
+ # Create a multidimensional subplot (grid) for all histograms
39
+ num_plots = len(numeric_columns)
40
+ rows = (num_plots + 1) // 2 # To create a 2-column grid layout for histograms
41
+ fig, axs = plt.subplots(rows, 2, figsize=(12, 12))
42
+ axs = axs.flatten() # Flatten the 2D array of axes to iterate over
43
 
44
  color_palettes_hist = ['Set1', 'Set2', 'Set3', 'Paired', 'Pastel1'] # Different color palettes for histograms
45
  for i, col in enumerate(numeric_columns):
 
50
  plt.clf()
51
 
52
  st.subheader("Boxplots for Numeric Columns:")
53
+ # Create a multidimensional subplot (grid) for all boxplots
54
+ fig, axs = plt.subplots(rows, 2, figsize=(12, 12))
55
+ axs = axs.flatten() # Flatten the 2D array of axes to iterate over
56
 
57
  color_palettes_box = ['coolwarm', 'Blues', 'viridis', 'cubehelix', 'crest'] # Different color palettes for boxplots
58
  for i, col in enumerate(numeric_columns):
 
73
  st.write(f"Value Counts for '{selected_cat_col}':")
74
  st.write(df[selected_cat_col].value_counts())
75
 
76
+ plt.figure(figsize=(12, 6))
77
  sns.countplot(x=selected_cat_col, data=df, palette='coolwarm') # Unique palette for categorical data
78
  plt.title(f'Bar Plot of {selected_cat_col}')
79
  st.pyplot(plt)