From 1fd219d4388adc797463e5faf698842d81934424 Mon Sep 17 00:00:00 2001 From: Hugo PRADIER Date: Wed, 5 Jun 2024 09:10:14 +0200 Subject: [PATCH] utilisation de is_numeric_dtype au lieu de verifier par type --- frontend/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/main.py b/frontend/main.py index f37c936..3de03a5 100644 --- a/frontend/main.py +++ b/frontend/main.py @@ -2,6 +2,7 @@ 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.title("Project Miner") @@ -49,9 +50,10 @@ if uploaded_file: st.pyplot(fig) st.subheader("Boxplot") - column_to_plot_box = st.selectbox("Select Column for Boxplot", data.columns, key="boxplot") - if column_to_plot_box: + 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(y=data[column_to_plot_box].dropna(), ax=ax) - ax.set_title(f'Boxplot of {column_to_plot_box}') - st.pyplot(fig) + 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