From fd3d6e3b0163c4848a6339c130b97f1781337b89 Mon Sep 17 00:00:00 2001 From: bastien ollier Date: Wed, 5 Jun 2024 09:51:48 +0200 Subject: [PATCH 1/3] debut merge --- frontend/{main.py => exploration.py} | 39 ++++++++++------------------ frontend/pages/visualization.py | 30 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 25 deletions(-) rename frontend/{main.py => exploration.py} (52%) create mode 100644 frontend/pages/visualization.py diff --git a/frontend/main.py b/frontend/exploration.py similarity index 52% rename from frontend/main.py rename to frontend/exploration.py index 79b9a64..b00a56a 100644 --- a/frontend/main.py +++ b/frontend/exploration.py @@ -9,13 +9,24 @@ st.set_page_config( layout="wide" ) +st.title("Home") + ### Exploration uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"]) -if uploaded_file: - data = pd.read_csv(uploaded_file) +if uploaded_file is not None: + st.session_state.data = pd.read_csv(uploaded_file) st.success("File loaded successfully!") +if "data" not in st.session_state: + st.session_state.data = None + + +if st.session_state.data is not None: + data = st.session_state.data + st.write(data.head(10)) + st.write(data.tail(10)) + st.header("Data Preview") st.subheader("First 5 Rows") @@ -39,26 +50,4 @@ if uploaded_file: st.subheader("Statistical Summary") st.write(data.describe()) - - ### Visualization - - st.header("Data Visualization") - - st.subheader("Histogram") - column_to_plot = st.selectbox("Select Column for Histogram", data.columns) - if column_to_plot: - fig, ax = plt.subplots() - ax.hist(data[column_to_plot].dropna(), bins=20, edgecolor='k') - ax.set_title(f'Histogram of {column_to_plot}') - ax.set_xlabel(column_to_plot) - ax.set_ylabel('Frequency') - st.pyplot(fig) - - st.subheader("Boxplot") - dataNumeric = data.select_dtypes(include='number') - column_to_plot = st.selectbox("Select Column for Boxplot", dataNumeric.columns) - if column_to_plot: - fig, ax = plt.subplots() - sns.boxplot(data=data, x=column_to_plot, ax=ax) - ax.set_title(f'Boxplot of {column_to_plot}') - st.pyplot(fig) \ No newline at end of file + \ No newline at end of file diff --git a/frontend/pages/visualization.py b/frontend/pages/visualization.py new file mode 100644 index 0000000..057b0c9 --- /dev/null +++ b/frontend/pages/visualization.py @@ -0,0 +1,30 @@ +import streamlit as st +import matplotlib.pyplot as plt +import seaborn as sns + +st.header("Data Visualization") + + +if "data" in st.session_state: + data = st.session_state.data + + st.subheader("Histogram") + column_to_plot = st.selectbox("Select Column for Histogram", data.columns) + if column_to_plot: + fig, ax = plt.subplots() + ax.hist(data[column_to_plot].dropna(), bins=20, edgecolor='k') + ax.set_title(f"Histogram of {column_to_plot}") + ax.set_xlabel(column_to_plot) + ax.set_ylabel("Frequency") + st.pyplot(fig) + + st.subheader("Boxplot") + dataNumeric = data.select_dtypes(include="number") + column_to_plot = st.selectbox("Select Column for Boxplot", dataNumeric.columns) + if column_to_plot: + fig, ax = plt.subplots() + sns.boxplot(data=data, x=column_to_plot, ax=ax) + ax.set_title(f"Boxplot of {column_to_plot}") + st.pyplot(fig) +else: + st.error("file not loaded") \ No newline at end of file -- 2.36.3 From c190656165a18932ae126bbab47385fdfac8aa89 Mon Sep 17 00:00:00 2001 From: bastien ollier Date: Fri, 7 Jun 2024 10:22:47 +0200 Subject: [PATCH 2/3] fix file not load --- frontend/exploration.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/exploration.py b/frontend/exploration.py index b00a56a..2becb9b 100644 --- a/frontend/exploration.py +++ b/frontend/exploration.py @@ -18,11 +18,8 @@ if uploaded_file is not None: st.session_state.data = pd.read_csv(uploaded_file) st.success("File loaded successfully!") -if "data" not in st.session_state: - st.session_state.data = None - -if st.session_state.data is not None: +if "data" in st.session_state: data = st.session_state.data st.write(data.head(10)) st.write(data.tail(10)) -- 2.36.3 From 6644d60fa271741caa9e91eecb654ba120b4127c Mon Sep 17 00:00:00 2001 From: clfreville2 Date: Fri, 7 Jun 2024 10:24:02 +0200 Subject: [PATCH 3/3] Remove unused imports --- frontend/exploration.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/exploration.py b/frontend/exploration.py index 2becb9b..123a22b 100644 --- a/frontend/exploration.py +++ b/frontend/exploration.py @@ -1,8 +1,5 @@ import pandas as pd import streamlit as st -import matplotlib.pyplot as plt -import seaborn as sns -from pandas.api.types import is_numeric_dtype st.set_page_config( page_title="Project Miner", @@ -47,4 +44,4 @@ if "data" in st.session_state: st.subheader("Statistical Summary") st.write(data.describe()) - \ No newline at end of file + -- 2.36.3