utilisation de is_numeric_dtype au lieu de verifier par type

This commit is contained in:
Hugo PRADIER
2024-06-05 09:10:14 +02:00
parent aa7b935de5
commit 1fd219d438

View File

@@ -2,6 +2,7 @@ import pandas as pd
import streamlit as st import streamlit as st
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import seaborn as sns import seaborn as sns
from pandas.api.types import is_numeric_dtype
st.title("Project Miner") st.title("Project Miner")
@@ -49,9 +50,10 @@ if uploaded_file:
st.pyplot(fig) st.pyplot(fig)
st.subheader("Boxplot") st.subheader("Boxplot")
column_to_plot_box = st.selectbox("Select Column for Boxplot", data.columns, key="boxplot") dataNumeric = data.select_dtypes(include='number')
if column_to_plot_box: column_to_plot = st.selectbox("Select Column for Boxplot", dataNumeric.columns)
if column_to_plot:
fig, ax = plt.subplots() fig, ax = plt.subplots()
sns.boxplot(y=data[column_to_plot_box].dropna(), ax=ax) sns.boxplot(data=data, x=column_to_plot, ax=ax)
ax.set_title(f'Boxplot of {column_to_plot_box}') ax.set_title(f'Boxplot of {column_to_plot}')
st.pyplot(fig) st.pyplot(fig)